This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: multiprocessing.Connection.poll raises BrokenPipeError on Windows
Type: behavior Stage:
Components: Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: zanchey
Priority: normal Keywords:

Created on 2020-06-17 14:59 by zanchey, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg371748 - (view) Author: David Adam (zanchey) Date: 2020-06-17 14:59
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
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85180
2020-06-17 14:59:25zancheycreate