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

kevin picture kevin · Feb 5, 2010 · Viewed 10.4k times · Source

I'm getting this error when doing database calls in a sub process using multiprocessing library.

Visit : Pastie

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

this is to a Postgre Database, using psycopg2 driver in web.py.

However if I use threading.Thread instead of multiprocessing.Process I don't get this error.
Any idea how to fix this?

Answer

Thomas Wouters picture Thomas Wouters · Feb 5, 2010

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.