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

被刻印的时光 ゝ 提交于 2020-01-04 02:35:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/2209560/internalerror-current-transaction-is-aborted-commands-ignored-until-end-of-tra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!