Multiple independently started python processes and sharing of a module

Martin P. Hellwig martin.hellwig at dcuktec.org
Fri Jan 14 05:51:01 EST 2011


On 01/14/11 10:05, Kushal Kumaran wrote:
<cut>
> This might help though:
> https://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
>
> It seems if you're not using 'daemon' mode, global data might be shared.
>
Yes I read that thoroughly before I started out implementing a solution.
But in my case I wanted something that worked as expected and not be 
depending on specific configuration of underlying technology as I can 
not assure that these condition will be met.

> You could create new connections for each request (and close them when
> done).  There won't be interference between select/fetch across
> multiple database connections.  Additionally, the documentation of
> MySQLdb says it is a bad idea to share database connections between
> threads.
>

That is a possible solution too, however the performance impact is in 
the range of 40% while doing forced synchronization and overhead of the 
singleton wrapper is around 20%. So the latter is what I have gone with.

Thanks for bouncing off ideas though, much appreciated.

-- 
mph





More information about the Python-list mailing list