Last active
January 3, 2016 22:09
-
-
Save max-lobur/8526120 to your computer and use it in GitHub Desktop.
Uncomment the eventlet line and it will hang! (Python 2.7.3) http://stackoverflow.com/questions/21242022/eventlet-hangs-when-using-futures-processpoolexecutor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eventlet | |
import futures | |
import random | |
import sys | |
#eventlet.monkey_patch(os=False) | |
def test(): | |
if random.choice((True, False)): | |
raise Exception() | |
print "OK this time" | |
def done(f): | |
print "done callback!" | |
def main(): | |
with futures.ProcessPoolExecutor(max_workers=2) as executor: | |
fu = [] | |
for i in xrange(6): | |
f = executor.submit(test) | |
f.add_done_callback(done) | |
fu.append(f) | |
futures.wait(fu, return_when=futures.ALL_COMPLETED) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^CProcess Process-2: | |
Process Process-1: | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap | |
self.run() | |
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run | |
self._target(*self._args, **self._kwargs) | |
File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/process.py", line 128, in _process_worker | |
call_item = call_queue.get(block=True) | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap | |
self.run() | |
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run | |
self._target(*self._args, **self._kwargs) | |
File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/process.py", line 128, in _process_worker | |
File "/usr/lib/python2.7/multiprocessing/queues.py", line 115, in get | |
self._rlock.acquire() | |
KeyboardInterrupt | |
Exception in thread Thread-1: | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner | |
self.run() | |
File "/usr/lib/python2.7/threading.py", line 504, in run | |
self.__target(*self.__args, **self.__kwargs) | |
File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/process.py", line 214, in _queue_management_worker | |
result_item = result_queue.get(block=True) | |
File "/usr/lib/python2.7/multiprocessing/queues.py", line 117, in get | |
res = self._recv() | |
KeyboardInterrupt | |
call_item = call_queue.get(block=True) | |
File "/usr/lib/python2.7/multiprocessing/queues.py", line 117, in get | |
res = self._recv() | |
KeyboardInterrupt | |
^CTraceback (most recent call last): | |
File "test.py", line 26, in <module> | |
main() | |
File "test.py", line 23, in main | |
futures.wait(fu, return_when=futures.ALL_COMPLETED) | |
File "/usr/local/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 277, in wait | |
waiter.event.wait(timeout) | |
File "/usr/lib/python2.7/threading.py", line 403, in wait | |
self.__cond.wait(timeout) | |
File "/usr/lib/python2.7/threading.py", line 243, in wait | |
waiter.acquire() | |
File "/usr/local/lib/python2.7/dist-packages/eventlet/semaphore.py", line 96, in acquire | |
hubs.get_hub().switch() | |
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 187, in switch | |
return self.greenlet.switch() | |
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 236, in run | |
self.wait(sleep_time) | |
File "/usr/local/lib/python2.7/dist-packages/eventlet/hubs/poll.py", line 81, in wait | |
sleep(seconds) | |
KeyboardInterrupt | |
Traceback (most recent call last): | |
File "/usr/lib/python2.7/multiprocessing/queues.py", line 266, in _feed | |
send(obj) | |
IOError: [Errno 32] Broken pipe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment