-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiprocessing hangs when Pool used within Process #49581
Comments
this occurs for me running on Mac OSX Leopard. The equivalent code from multiprocessing import Pool, Process
import sys
def f(x):
return x*x
def go():
pool = Pool(processes=4)
x = pool.map(f, [1, 2, 3, 4, 5, 6, 7])
sys.stdout.write("result: %s\n" % x)
def go2():
x = map(f, [1,2,3,4,5,6,7])
sys.stdout.write("result: %s\n" % x)
# pool alone, fine
go()
# process alone, fine
p = Process(target=go2)
p.start()
p.join()
# use both, hangs
p = Process(target=go)
p.start()
p.join() |
Fails also on this system. $ p3
Python 3.0.1 (r301:69556, Feb 13 2009, 23:52:55)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
(...)
>>> # use both hangs
(...)
>>> p.start()
>>> p.join()
(hmm la do diii laaa...)^C
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/usr/users/lambert/bin/python/lib/python3.0/multiprocessing/process.py",
line 119, in join
res = self._popen.wait(timeout)
File
"/usr/users/lambert/bin/python/lib/python3.0/multiprocessing/forking.py",
line 118, in wait
return self.poll(0)
File
"/usr/users/lambert/bin/python/lib/python3.0/multiprocessing/forking.py",
line 107, in poll
pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
>>> |
Apparently the pool workers die all at once, just after the pool creates except (EOFError, IOError):
import traceback
debug(traceback.format_exc())
debug(''.join(traceback.format_stack()))
debug('worker got EOFError or IOError -- exiting')
break INFO::Rule dispatcher::multiprocessing::child process calling self.run()
DEBUG::Rule dispatcher::multiprocessing::created semlock with handle
3082559488
DEBUG::Rule dispatcher::multiprocessing::created semlock with handle
3082104832
DEBUG::Rule dispatcher::multiprocessing::created semlock with handle
3081826304
DEBUG::Rule dispatcher::multiprocessing::created semlock with handle
3081822208
INFO::PoolWorker-3:1::multiprocessing::child process calling self.run()
DEBUG::PoolWorker-3:1::multiprocessing::Traceback (most recent call last):
File
"/home/who/.buildout/eggs/multiprocessing-2.6.1.1-py2.6-linux-i686.egg/multiprocessing/pool.py",
line 57, in worker
task = get()
File
"/home/who/.buildout/eggs/multiprocessing-2.6.1.1-py2.6-linux-i686.egg/multiprocessing/queues.py",
line 339, in get
return recv()
IOError: [Errno 9] Bad file descriptor DEBUG::PoolWorker-3:1::multiprocessing:: File DEBUG::PoolWorker-3:1::multiprocessing::worker got EOFError or IOError |
It seems the root cause is at http://bugs.python.org/issue5155 . |
Patch attached to bpo-5313, please review |
Committed in r73708 on trunk |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: