New submission from Thomas Grainger <tagr...@gmail.com>:
The docs for https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Queue.close read: > Indicate that no more data will be put on this queue by the current process. > The background thread will quit once it has flushed all buffered data to the > pipe. This is called automatically when the queue is garbage collected. >From this text it seems to me as though the queue should be used as follows: import contextlib import multiprocessing def worker(q): with contextlib.closing(q): q.put_nowait('hello') def controller(): q = multiprocessing.Queue() q.close() # no more 'put's from this process p = multiprocessing.Process(target=worker, args=(q, )) p.start() assert q.get() == 'hello' p.join() assert p.exitcode == 0 print('OK!') if __name__ == '__main__': controller() however I get this: Traceback (most recent call last): File "controller.py", line 22, in <module> controller() File "controller.py", line 15, in controller assert q.get() == 'hello' File "/usr/lib/python3.7/multiprocessing/queues.py", line 94, in get res = self._recv_bytes() File "/usr/lib/python3.7/multiprocessing/connection.py", line 212, in recv_bytes self._check_closed() File "/usr/lib/python3.7/multiprocessing/connection.py", line 136, in _check_closed raise OSError("handle is closed") OSError: handle is closed ---------- messages: 339847 nosy: graingert priority: normal severity: normal status: open title: multiprocessing.Queue.close doesn't behave as documented _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com