[New-bugs-announce] [issue42631] Multiprocessing module hangs on os.read() on Linux

to7m report at bugs.python.org
Sun Dec 13 18:37:58 EST 2020


New submission from to7m <thomashowemain at gmail.com>:

As best I can tell, sometimes when a Listener or Connection is not properly initialised, the Client fails to communicate properly with it. Instead of raising an exception, the Client hangs.


receiver.py:


from multiprocessing.connection import Listener

while True:
    with Listener(("localhost", 10000), authkey=b"test") as listener:
        with listener.accept() as connection:
            print(connection.recv())


client.py (intended as a stress test):


from multiprocessing.connection import Client

for i in range(1000):
    successfully_sent = False
    while not successfully_sent:
        try:
            with Client(("localhost", 10000), authkey=b"test") as client:
                client.send(i)
        except (ConnectionRefusedError, ConnectionResetError):
            continue
        successfully_sent = True


Also noteworthy: I posted on StackExchange (https://stackoverflow.com/questions/65276145/multiprocessing-receive-all-messages-from-multiple-runtimes) and it seems that the code there (only 1000 messages) took around an hour to run for a Windows user, whereas it would take less than a second to successfully run on Linux.

----------
components: IO
files: receive.py
messages: 382945
nosy: to7m
priority: normal
severity: normal
status: open
title: Multiprocessing module hangs on os.read() on Linux
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49675/receive.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42631>
_______________________________________


More information about the New-bugs-announce mailing list