-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug on commit() #108
Comments
I just tested the same code and it works perfectly fine on my end.
is most likely being thrown because you have a different process/thread trying to commit to the same sqlite db at the same time. Try completely restarting your computer (to make sure any orphaned/backgrounded tasks get killed) and see if you can reproduce the issue consistently. Additionally see if you can reproduce the issue even after changing the db file name so you're 100% sure nothing else can be writing to the db |
The problem is not to understand why I'm getting the exception. The problem is that sqlitedict is not responding in the right way when there is an exception on the underlying commit operation. The current behavior is to hang indefinitely without ever returning and this cannot be the right behavior, right? |
Quick fix could be adding |
Was anything ever done to fix this? The "quick fix" doesn't appear possible because there doesn't seem to be a way to pass sqlite connection params to sqlitedict. The connection happens inside sqlitedict. Maybe what's needed is another arg to sqlitedict constructor. Something like (dict) connect_params, a dictionary of arguments for sqlite3.connect. Then pass it to connect as kwargs. I don't see any code in sqlitedict.commit () that would swallow an exception. My guess is that acortiana did something more besides just wrapping conn.commit () in try / except. Although it seems he's using the multithread class based on line number, so perhaps it's a thread issue (exception gets raised and silently swallowed, or error message output is ignored, in a secondary thread, but error propagates all the way to the top when testing with one thread). |
I did this test to better demonstrate the problem:
just after this line:
I added the "hasattr" condition to skip the first commit from the "HiThere" exception. Executing the code, you can see that the Thread-1 raises the exception but you can also see that mydict.commit() command remains stuck without ever returning. |
I'm using sqlitedict version 1.6.0 and Python version 3.6.9
If I do this
and the commit fails for some reason, the
mydict.commit()
line hangs and never returns.
I think that the problem is here, maybe a try/except is needed, with some error handling code:
https://github.com/RaRe-Technologies/sqlitedict/blob/39e8dced2f56498df6e0d58a0addf42297917d3f/sqlitedict.py#L404
I tried to add a try/except and, in my case, I got this error:
The text was updated successfully, but these errors were encountered: