Pergunta

I'm using Ubuntu 12.04 Server x64, Python 2.7.3, futures==2.1.5, eventlet==0.14.0

Did anybody hit the same problem?

import eventlet
import futures
import random

# eventlet.monkey_patch() # Uncomment this line and it will hang!

def test():
    if random.choice((True, False)):
        raise Exception()
    print "OK this time"

def done(f):
    print "done callback!"

def main():
    with futures.ProcessPoolExecutor() 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 code, if you uncomment the line, will hang. I can only stop it by pressing Ctrl+C. In this case the following KeyboardInterrupt traceback is printed: https://gist.github.com/max-lobur/8526120#file-traceback

This works fine with ThreadPoolExecutor.

Any feedback is appreciated

Nenhuma solução correta

Outras dicas

I think this KeyboardInterrupt reaches the started process because under ubuntu and most linux systems the new process is created with fork - starting a new process from the current one with the same stdin and stdout and stderr. So the KeyboardInterrupt can reach the child process. Maybe someone who know something more can add thoughts.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top