Coordinating access to a non-thread-safe db

VanL vlindberg at verio.net
Mon Mar 31 18:48:43 EST 2003


Hello,

I am writing some code that needs to respond to two circumstances:
1. User input via an event-driven interface
2. The passing of a certain amount of time (a la cron)

I am planning to use the sched and threading modules to do this.  
However, I need to access a database that is only threadsafe at level 1 
(sqlite) and so I am unsure how to coordinate database access such that 
nothing gets corrupted.  My initial thought was to implement a 
DBController thread, and defer all database access to that thread.  
However, I have not written very many multithreaded programs, and I am 
not sure that my intinct is correct.

Does anyone have any experience or code that deals with this problem?

Thanks,

VanL






More information about the Python-list mailing list