Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 819
kevin Avatar asked Feb 28 '23 15:02

kevin


1 Answers

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.

like image 133
Thomas Wouters Avatar answered Apr 18 '23 19:04

Thomas Wouters