On Jun 14, 2006, at 12:06 PM, Ed Suominen wrote:

> I'm getting the following error from my running connection.close():
>
>> 'SQLite objects created in a thread can only be used in that same
>> thread.The object was created in thread id 1098918240 and this is
>> thread id 47075765124944' in <bound method ConnectionFairy.__del__ of
>> <sqlalchemy.pool.ConnectionFairy object at 0x2aaaaabd6f10>>
>
> The error shows up about 1/4 of the time, equally often whether I'm
> using strategy='threadlocal' or not.
>
> It looks like SA is spawning a thread somewhere as I am going to great
> lengths to keep everything running in a single worker thread.

SA does not spawn threads.

> What can I
> do to avoid this error? The code in question is at
> http://foss.eepatents.com/sAsync/browser/trunk/sasync/database.py,  
> line 311.
>

the SQLite engine will enforce the usage of the SingletonThreadPool  
which stores connections on a thread-local basis, meaning within a  
certain thread, you will get the same connection every time, and that  
connection will never be returned for a different thread.

so whatever is happening, you are somehow getting a connection out of  
the pool and passing it off to another thread somewhere thats trying  
to use it, which then causes SQLite to complain.  the stack trace  
corresponding to your error there should give you clues.





_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to