私が解決できなかった奇妙な例外を見つけました...誰かが間違ったことや新しいデザインを提案することはできますか?私はGunicorn/Flaskアプリケーションを実行しています。設定ファイルで、私はon_starting
フック[1]で行う作業を指定します。そのフックコード内では、私はこのようないくつかのコード(空想何を)持っている:Gunicorn + Subprocessesが例外を発生する[Errno 10]
# Called before the server is started
my_thread = package.MyThread()
my_thread.start()
package.MyThreadクラスは次のようになります。 ls
コマンドは重要ではなく、どのコマンドでもかまいません。サーバーの起動時に
class MyThread(threading.Thread):
"""
Run a command every 60 seconds.
"""
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()
def run(self):
while not self.event.is_set():
ptest = subprocess.Popen(["ls"], stdout=subprocess.PIPE)
ptest.communicate()
self.event.wait(60)
def stop(self):
self.event.set()
、私は常にこの例外を提示しています:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "__init__.py", line 195, in run
ptest.communicate()
File "/usr/lib64/python2.6/subprocess.py", line 721, in communicate
self.wait()
File "/usr/lib64/python2.6/subprocess.py", line 1288, in wait
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
File "/usr/lib64/python2.6/subprocess.py", line 462, in _eintr_retry_call
return func(*args)
OSError: [Errno 10] No child processes
誰もがここで何が起こっているかをお勧めすることはできますか?私は[2]の変更を実装しようとしていない、彼らはハッキーのようだ。
[1] - http://gunicorn.org/configure.html#server-hooks
[2] - Popen.communicate() throws OSError: "[Errno 10] No child processes"
ガンコンの新しいバージョンはこれを回避します(おそらく、 'SIGCHLD'を傍受することはないでしょう)。私のテストでは、Python 2.6でもgunicorn 0.14.xに移行するだけで十分でした。 –