You are not logged in.
Hi, I got a Database manager, it starts in background and waits someone to call add_task, when it does, the ask then is executed, and the content is then applied in the db.
But it raises an error, says:
ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id -1218516784 and this is thread id -1223136400
This is the code: http://paste.pocoo.org/show/252409/
P.S: If someone can tell me where can I find some module which does that for me, for instance wait in the background for tasks.
Edit: typo .
Last edited by gnu_D (2010-08-20 13:43:54)
:: Python powered FOREVER ::
Offline
A nice database handler: Sqlalchemy (http://www.sqlalchemy.org/)
Read the docs, there are examples how to manage threading and connection pooling.
Here is a specific section on threading:
http://www.sqlalchemy.org/docs/referenc … g-behavior
It does also clarifiy how to make your programm threadsafe.
Last edited by simlan (2010-08-26 06:26:35)
{ Github } {Blog and other stuff }
Offline
Actually I tried, but the same thing happend.
So I left it be .
:: Python powered FOREVER ::
Offline
sqlite does not work well (at all?) with threaded / multiproc code accessing one database, unless you handle locking yourself. Just dont do it.
http://www.sqlite.org/faq.html#q5
http://www.sqlite.org/faq.html#q6 (note the section on specific compilation options)
If you need db access, and you need threading, I recommend you use some type of locking singleton that receives messages from worker threads, ala Actors or something.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
The other obligatory question is: Why threads? With python threads you can't run more than one task at a time anyway.
You might want to consider some async lib ala twisted instead.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline