Re: psycopg2 multiprocessing problem

kevin <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Mon, Feb 8, 2010 at 2:44 AM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote:

> On 07/02/2010 19:43, kevin wrote:
> > i am getting this error message in pg_log log directory
> >
> > http://pastie.org/813651
> >
> > i do not think there are any error in the queries [select,
> insert/updates] i
> > am doing, because if i switch to threading instead of multiprocessing i
> dont
> > get any error at all. but i want to use multiprocessing.
>
> It seems you're using the same connection from two processes at the same
> time. Threads use the same address space, so they can share the
> connection because locks and shared state works. I suppose the fork()
> done by multiprocess duplicates file descriptors so that the pq
> connection continue to work but now you have two python connections that
> don't share the same state anymore and this is bad (no locking and so
> on). Just create a new connection in every process.
>
> psycopg law number 0: never share a connection between processes.
>
> thanks a lot for all the  info. my python script is something like
http://pastie.org/814709

is there any option that i can use to ensure new connection is created for
new processes? or how do i manually create new connection for new processes?
thanks a lot

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.