sqlite3.ProgrammingError: Recursive use of cursors not allowed.
While searching for new term this app throws the following error.
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/dash/dash.py", line 967, in dispatch
return self.callback_map[target_id]['callback'](*args)
File "/home/n3011/miniconda3/envs/twitter/lib/python3.6/site-packages/dash/dash.py", line 907, in add_context
output_value = func(*args, **kwargs)
File "/home/n3011/work/twitter/socialsentiment/dash_mess.py", line 228, in update_pie_chart
sentiment_pie_dict = cache.get('sentiment_shares', sentiment_term)
File "/home/n3011/work/twitter/socialsentiment/cache.py", line 41, in get
result = self.cursor.execute("SELECT value FROM {} WHERE key = ?".format(pool), (key,)).fetchone()
sqlite3.ProgrammingError: Recursive use of cursors not allowed.
After spending hours, i managed to solve the same issue. You have to make the following appends to the cache.py file: 1. Add the
`import time import os from threading import Lock
#Define the lock globally to avoid the "recursive use of cursors not allowed" error lock= Lock()`
at the top
- Add the following line before every self.cursor operation
#lock the cursor lock.acquire(True)
-
Add the following line after every cursor operation in the same .py file.
#release the cursor lock.release()
` #lock the cursor lock.acquire(True)
# get data from cache
result = self.cursor.execute("SELECT value FROM {} WHERE key = ?".format(pool), (key,)).fetchone()
#release the cursor
lock.release()`
but still getting the same error socialsentiment/cache.py", line 48, in get result = self.cursor.execute("SELECT value FROM {} WHERE key = ?".format(pool), (key,)).fetchone() sqlite3.ProgrammingError: Recursive use of cursors not allowed.
cache.txt I have uploaded the python code (in txt format) so that you can maybe re-apply.
@Sailor74 i tried with your code but it still giving the same error

please help me to find out the exact issue.
ok interesting.. it could be one of the below solutions. Pls give them a try at your own risk.
your requirements should include the following libraries. Check if you are missing any. dash dash-core-components dash-html-components dash-renderer dash-table tweepy vaderSentiment unidecode plotly pandas regex python-memcached h5py numpy Werkzeug textblob
Secondly if you have anaconda, it maybe causing some conflicts:
- Make sure you have Python3.6+. My best idea here is to get rid of Anaconda and venvs and do it the regular way
- Maybe try to remove sql database file and start it again?
- uninstall the dash files and install the older version.
python -m pip install --upgrade pysqlite3
Also venv...Activate that venv Run Python
good luck...
Thank you,
Özgür
On Tue, Apr 9, 2019 at 4:58 PM udipta [email protected] wrote:
@Sailor74 https://github.com/Sailor74 i tried with your code but it still giving the same error [image: Screenshot from 2019-04-10 02-23-33] https://user-images.githubusercontent.com/28093579/55834794-4d054d00-5b38-11e9-8df5-2dc5d063c2d6.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sentdex/socialsentiment/issues/12#issuecomment-481433190, or mute the thread https://github.com/notifications/unsubscribe-auth/AI1SJ2C1WACEJJvzAP07MXgQ4HQ85psbks5vfP8EgaJpZM4Z8icI .
@Sailor74 did you try to run the code before in your system? because I am again and again getting the same error and I am not able to figure it out.
Of course... it is live at social.ozgurgenc.dev
Özgür Genç Sent from my iPhone +1 646 946 2389 Please disregard spelling errors.
From: udipta [email protected] Sent: Wednesday, April 10, 2019 10:46 AM To: Sentdex/socialsentiment Cc: Ozgur Genc; Mention Subject: Re: [Sentdex/socialsentiment] sqlite3.ProgrammingError: Recursive use of cursors not allowed. (#12)
@Sailor74https://github.com/Sailor74 did you try to run the code before in your system? because I am again and again getting the same error and I am not able to figure it out.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Sentdex/socialsentiment/issues/12#issuecomment-481721772, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AI1SJ8J1GARnoXLlVEkajUaG9ag4vaCLks5vfflRgaJpZM4Z8icI.
@Sentdex @Sailor74 How to resolve the error. socialsentiment/cache.py", line 48, in get result = self.cursor.execute("SELECT value FROM {} WHERE key = ?".format(pool), (key,)).fetchone() sqlite3.ProgrammingError: Recursive use of cursors not allowed.
I have tried every solution but unable to resolve.
I have it fully working in conda environment after receiving this error...remove any *.db files and py cache folder in your sentiment directory. Run twitter_stream.py, leave it open and in another terminal run the dev_server. This is using cache.py from repo non modified. however I did use these pip install ... dash==0.30.0 dash-core-components==0.38.0 dash-html-components==0.13.2 dash-renderer==0.15.0
Adding the locks solved the error for me, but made the GUI very slow. @Sailor74 i think you posted the incorrect cache.py file, it has no locks. Can you please check?
Follow
- @chris-ault Steps
- Steps to incorporate locks in every cursor operation as mentioned by @Sailor74
- Run dev_server.py
it works, and i see no lag in the response as far as speed is concerned.