[New-bugs-announce] [issue41008] multiprocessing.Connection.poll raises BrokenPipeError on Windows

David Adam report at bugs.python.org
Wed Jun 17 10:59:25 EDT 2020


New submission from David Adam <zanchey at ucc.gu.uwa.edu.au>:

On Windows 10 (1909, build 18363.900) in 3.7.7 and 3.9.0b3, poll() on a multiprocessing.Connection object can produce an exception:

--
import multiprocessing

def run(output_socket):
    for i in range(10):
        output_socket.send(i)
    output_socket.close()

def main():
    recv, send = multiprocessing.Pipe(duplex=False)
    process = multiprocessing.Process(target=run, args=(send,))
    process.start()
    send.close()

    while True:
        if not process._closed:
            if recv.poll():
                try:
                    print(recv.recv())
                except EOFError:
                    process.join()
                    break

if __name__ == "__main__":
    main()
--

On Linux/macOS this prints 0-9 and exits successfully, but on Windows produces a backtrace as follows:

  File "mptest.py", line 17, in main
    if recv.poll():
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.179.0_x64__qbz5n2kfra8p0\lib\multiprocessing\connection.py", line 262, in poll
    return self._poll(timeout)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.179.0_x64__qbz5n2kfra8p0\lib\multiprocessing\connection.py", line 333, in _poll
    _winapi.PeekNamedPipe(self._handle)[0] != 0):
BrokenPipeError: [WinError 109] The pipe has been ended

----------
messages: 371748
nosy: zanchey
priority: normal
severity: normal
status: open
title: multiprocessing.Connection.poll raises BrokenPipeError on Windows
type: behavior
versions: Python 3.9

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


More information about the New-bugs-announce mailing list