Skip to content

Instantly share code, notes, and snippets.

@max-lobur
Last active January 3, 2016 22:09
Show Gist options
  • Save max-lobur/8526120 to your computer and use it in GitHub Desktop.
Save max-lobur/8526120 to your computer and use it in GitHub Desktop.
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()
^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