Michael added the comment:

I found a couple of other cases when deadlock still occurs.

1. _help_stuff_finish may remove sentinels from the queue. Some of the workers 
will then never get a signal to terminate.

2. worker handler thread may be terminated too late, so it may spawn new 
workers while terminating is in progress.

I tried to fix these two issues too in following commit: 
https://github.com/michael-a-cliqz/cpython/commit/3a767ee7b33a194c193e39e0f614796130568630

NB: This updated snippet has higher chances for deadlock:

"""
import logging
import multiprocessing.pool
import signal
import time

def foo(num):
    return num * num

def signal_handler(signum, frame):
    pass

if __name__ == '__main__':
    signal.signal(signal.SIGTERM, signal_handler)

    logger = multiprocessing.log_to_stderr()
    logger.setLevel(logging.DEBUG)

    pool = multiprocessing.pool.Pool(processes=16)
    time.sleep(0.5)
    pool.map_async(foo, range(16))
    pool.terminate()
"""

(I am running it from dead loop in a shell script)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29759>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to