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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With