Delgan <delgan...@gmail.com> added the comment:

Thank you for having looked into the problem.

To be more specific, I don't generally mix threads with multiprocessing, but 
it's a situation where there is one global and hidden consumer thread listening 
to a queue for non-blocking logging.

Actually, I think the problem is reproducible using the QueueListener provided 
in "logging.handlers". The following snippet is inspired by this part of the 
documentation: 
https://docs.python.org/3/howto/logging-cookbook.html#dealing-with-handlers-that-block

----------------------

import logging
import multiprocessing
import queue
from logging.handlers import QueueHandler, QueueListener


if __name__ == "__main__":
    que = multiprocessing.Queue()
    
    queue_handler = QueueHandler(que)
    handler = logging.StreamHandler()
    listener = QueueListener(que, handler)
    root = logging.getLogger()
    root.addHandler(queue_handler)
    listener.start()

    for i in range(10000):
        root.warning('Look out!')
        p = multiprocessing.Process(target=lambda: None)
        p.start()
        p.join()
        print("Not hanging yet", i)


    listener.stop()

----------

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

Reply via email to