views:

665

answers:

1

i am getting this error when doing database calls in a sub process using multiprocessing library.

http://pastie.org/811424

InternalError: current transaction is aborted, commands ignored until end of transaction block

this is to a postgres database, using psycopg2 driver in web.py.

how ever if i use threading.Thread instead of multiprocessing.Process I dont get this error. any ideas how to fix this?

+4  A: 

multiprocessing works (on UNIX systems) by forking the current process. If you have an existing database connection, this will leave the two processes (the current one and the new one) with the same database connection. Trying to use it from both is bad. Create a new database connection in the child process instead.

Thomas Wouters