MySQLdb multithreaded

Greg Fortune lists at gregfortune.com
Wed May 7 16:11:54 EDT 2003


Right, but unless you implement locking in your app, the threads can't share 
the connection because you don't know when each thread might be accessing the 
connection.  So, unless you are already explicitly doing locking, the 
definition is exactly right.  For anyone else still reading, you might check 
out Andy Dustman's Pool module that will allow the type of behavior Skip 
describes.

Greg

On Wednesday 07 May 2003 11:51 am, Skip Montanaro wrote:
>     Greg> Integer constant stating the level of thread safety the interface
>     Greg> supports.  Possible values are:
>
>     Greg> 0= Threads may not share the module.
>     Greg> 1= Threads may share the module, but not connections.
>     Greg> 2= Threads may share the module and connections.
>     Greg> 3= Threads may share the module, connections and cursors.
>
>     Greg> MySQLdb.threadsafety == 1 for the latest version so each thread
>     Greg> must have its own connection.
>
> Yes, but I think the definition of threadsafety == 1 is perhaps a bit
> misleading.  Only one thread at a time may access a connection, but the
> connection doesn't have to be thrown away after that thread is done with
> it. (Maybe the definition is clear, but MySQLdb is actually more like a
> 1.5.)
>
> Skip





More information about the Python-list mailing list