-
Notifications
You must be signed in to change notification settings - Fork 97
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
Error on attempting to use the same connection in multiple threads. #31
Comments
From rogerbinns on October 24, 2008 14:42:43 I apologize for the documentation inaccuracy. Before SQLite 3.5 you had to use the I am in the middle of moving the documentation to the Sphinx tool which results in That said, I cannot reproduce this issue. The test suite already does all sorts of Owner: rogerbinns |
From amicitas on October 24, 2008 16:28:11 I'll try to reproduce this over the weekend. The place where it was happening was It was happening when I tried to execute a query from one thread while another I did just upgrade from python 2.5 to 2.6 and I noticed (just now) that I had not -- amicitas |
From rogerbinns on October 24, 2008 16:46:09 You certainly can't use an extension compiled for Python 2.5 with Python 2.6 under Python 2.6 ( r26 :66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
I have added some select iteration to the test as well and still don't see any failures. The only thing I can think of that could cause your issue that is SQLite related is In general it is a good idea to share the same connection across threads as they will I'm looking forward to your code reproduction :) |
From amicitas on October 26, 2008 14:20:27 Ok I found it. This happens when a function is defined using "createscalarfunction()". (It took me a Attached is some test code that reproduces the problem for me. I have only tested Let me know if you need more information. -- amicitas btw, what happened with my upgrade to python 2.6 was that although I upgraded, I was Attachment: apsw_bug.py |
From rogerbinns on October 26, 2008 15:18:13 Thank you for that. I can confirm the problem. The lockup results when Python and It affects all operating systems. Attached is a simpler version of the code to Status: Started Attachment: issue31.py |
From rogerbinns on October 26, 2008 15:18:36 Labels: -Priority-Medium Priority-Critical |
From rogerbinns on October 26, 2008 18:08:28 I have found the cause. The issue also applies to pysqlite but pysqlite doesn't let To run a query ultimately sqlite3_step is called. Just before calling it, the Python In another thread, the Python GIL is acquired and then a call is made to a sqlite3_* If the GIL had been released in the second thread before calling the sqlite3_ (Registering a scalar function was a red herring. It just changed the timing enough There are 3 solutions:
Second is rather expensive since it involves releasing and acquiring a mutex on every |
From rogerbinns on October 28, 2008 00:00:11 I took the second approach except for a few functions where it is not necessary to Fixed in r299 . Status: Verified |
From rogerbinns on November 05, 2008 01:52:22 On further work I established that you can't get SQLite error messages in a (Unless the SQLite 3.6.5 release is seriously delayed in which case a work around can |
From amicitas on October 24, 2008 13:05:39
What steps will reproduce the problem? 1. Attempt to simultaneously use the same connection in two threads. What is the expected output? What do you see instead? It would be very nice if an error was raised if this is attempted. At this
point the application just hangs with no error output. What version of the product are you using? On what operating system? apsw 3.5.9- r2 , python 2.5 & 2.6, windows xp sp3 Please provide any additional information below. The documentation does clearly state that a connection cannot be used in
more than one thread. If it is attempted the application just hangs. Both
threads stop as well as the main program. I would be nice if an error was
thrown as it is if the cursor is used in two threads.
-- amicitas
Original issue: http://code.google.com/p/apsw/issues/detail?id=31
The text was updated successfully, but these errors were encountered: