psycopg とマルチプロセッシングを使用して、数百万行を挿入および更新しようとしています。http://initd.org/psycopg/docs/usage.html#thread-and-process-safetyにあるドキュメントによると、各子には DB への独自の接続があります。
しかし、処刑の過程で、一人の子供だけが走り、他の子供たちはゾンビになります。スクリプト自体は非常にシンプルで、これをトリミングしたものを次に示します。
import os
import psycopg2
from multiprocessing import Process
def _target(args):
# Each forked process will have its own connection
# http://initd.org/psycopg/docs/usage.html#thread-and-process-safety
conn = get_db_connection()
# Stuff seems to execute till this point in all the children
print os.getpid(), os.getppid()
# Do some updates here. After this only one child is active and running
# Others become Zombies after a while.
if __name__ == '__main__':
args = "Foo"
for i in xrange(3):
p = Process(target=_target, args=(args,))
p.start()
また、 を覗いて、テーブルにエスカレートされたロックがあるかどうかを確認しましたpg_locks
が、そうではないようです。明らかな何かが欠けていますか?