开发者

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

开发者 https://www.devze.com 2022-12-19 13:44 出处:网络
I\'m getting this error when doing database calls in a sub process using multiprocessing library. Visit : Pastie

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消