1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python multiprocessing.Queue strange behaviour

Discussão em 'Python' iniciado por Stack, Abril 17, 2025.

  1. Stack

    Stack Membro Participativo

    Hi I'm observing a strange behaviour with python multiprocessing Queue object.

    My environment:

    OS: Windows 10
    python: 3.13.1


    but I observed the same with:

    OS: Windows 10
    python: 3.12.7


    and:

    OS: Windows 10
    python: 3.10.14


    while I could not reproduce it in Linux Redhat.

    I have this short script:

    from multiprocessing import Queue

    a = list(range(716))
    queue: Queue = Queue()
    for item in a:
    queue.put(item)
    raise ValueError(f"my len: {len(a)}")


    If I run it, everything is ok, it raises the error and exits:

    Traceback (most recent call last):
    File "C:\Users\uXXXXXX\AppData\Roaming\JetBrains\PyCharmCE2024.3\scratches\scratch_1.py", line 7, in <module>
    raise ValueError(f"my len: {len(a)}")
    ValueError: my len: 716

    Process finished with exit code 1


    but if i change the number from 716 to 717 or any other number above it, it raises the error but doesn't exit, the script hangs there. and when I forcefully stop the script it exits with code -1

    Traceback (most recent call last):
    File "C:\Users\uXXXXXX\AppData\Roaming\JetBrains\PyCharmCE2024.3\scratches\scratch_1.py", line 7, in <module>
    raise ValueError(f"my len: {len(a)}")
    ValueError: my len: 717

    Process finished with exit code -1


    Can you please help me solve this strange behaviour? i would like it to always automatically exit with code 1

    Continue reading...

Compartilhe esta Página