-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed as not planned
Closed as not planned
Copy link
Description
Bug report
Bug description:
I am using the following version of Python:
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32.
Here is my code:
import multiprocessing
def sub_process(queue):
print("Sub process started")
data = queue.get()
print(f"Sub process received {data} from main process")
queue.put("Hello from sub process")
print("Sub process finished")
if __name__ == "__main__":
queue = multiprocessing.Queue()
p = multiprocessing.Process(target=sub_process, args=(queue,))
p.start()
queue.put("Hello from main process")
print("Main process sent data to sub process")
data = queue.get()
print(f"Main process received {data} from sub process")
p.join()
This code works normally in Linux with Python 3.10.4. However, it does not work properly on Windows and gets stuck at data = queue.get()
in the sub_process
method.
PS D:\project\my-py-project> python .\test.py
Main process sent data to sub process
Main process received Hello from main process from sub process
Sub process started
Process Process-1:
Traceback (most recent call last):
File "C:\me\software\python\python311\Lib\multiprocessing\process.py", line 314, in _bootstrap
self.run()
File "C:\me\software\python\python311\Lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "D:\project\my-py-project\test.py", line 4, in sub_process
data = queue.get()
^^^^^^^^^^^
File "C:\me\software\python\python311\Lib\multiprocessing\queues.py", line 103, in get
res = self._recv_bytes()
^^^^^^^^^^^^^^^^^^
File "C:\me\software\python\python311\Lib\multiprocessing\connection.py", line 215, in recv_bytes
buf = self._recv_bytes(maxlength)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\me\software\python\python311\Lib\multiprocessing\connection.py", line 304, in _recv_bytes
waitres = _winapi.WaitForMultipleObjects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
Traceback (most recent call last):
File "D:\project\my-py-project\test.py", line 17, in <module>
p.join()
File "C:\me\software\python\python311\Lib\multiprocessing\process.py", line 149, in join
res = self._popen.wait(timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\me\software\python\python311\Lib\multiprocessing\popen_spawn_win32.py", line 109, in wait
res = _winapi.WaitForSingleObject(int(self._handle), msecs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
CPython versions tested on:
3.11
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
No labels