Skip to content

multiprocessing.Queue does pickling in a worker thread, thus pickling errors don't generate helpful tracebacks. #109554

@remdragon

Description

@remdragon

Bug report

Bug description:

I recently got the following traceback in my code:

Traceback (most recent call last):
  File "multiprocessing\queues.py", line 244, in _feed
  File "multiprocessing\reduction.py", line 51, in dumps
TypeError: cannot pickle '_thread.RLock' object

Unfortunately, there's nothing about this traceback that is useful or helpful to me. I started digging through the logic and it appears that multiprocessing.Queue has a worker thread where it does the pickling. The unfortunate side-effect of this is that if there a pickling error, it doesn't happen in a useful context. If the pickling could happen before the data is handed off to the worker thread, then a much more useful traceback could be generated.

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions