multiprocessing.Queue.empty() returns False after all producers have exited on Windows 3.13.3
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
On Windows 11 with CPython 3.13.3 official installer, Queue.empty() incorrectly returns False when the producer process has already terminated, allowing a later-started consumer to successfully get() all buffered items. This contradicts the documented behaviour that empty() is only reliable while producers are alive.
To Reproduce
Save as clean_test.py:
Python
from multiprocessing import Process, Queue
def x(q):
for i in range(4):
q.put(i)
def y(q):
cnt = 0
while True:
if q.empty():
break
q.get()
cnt += 1
print('实际 get 次数:', cnt)
if __name__ == '__main__':
q = Queue()
p1 = Process(target=x, args=(q,))
p2 = Process(target=y, args=(q,))
p1.start()
p1.join() # producer already dead
p2.start()
p2.join()
Run:
powershell
python clean_test.py
Expected behaviour
Should print 实际 get 次数: 0 (consumer sees empty queue).
Actual behaviour
Prints 实际 get 次数: 4 (consumer successfully gets all items).
Environment
OS: Windows 11 (build 22631)
Python: 3.13.3 (tags/v3.13.3:6280bb5, Apr 8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)]
Installer: official python.org x64 exe
File SHA-256: 4D8746575FF5D9062D159EB0C382589DBFEC56C942D23DA57E44CF1920312D57
Additional context
The same script always outputs 0 on Linux (CPython 3.11-3.13) and on Windows 10 with 3.11.
Appears to be Windows-specific and version-specific (3.13.3).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the clean_test.py reproducer and run it on Windows 11 with CPython 3.13.3, then compare the Windows 10 and Linux results described in the issue. Investigate multiprocessing.Queue.empty() and the producer/consumer lifecycle; done means the Windows 3.13.3 case reports 0 items after the producer exits without regressing the comparison environments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100