[Django] #37063: PicklingError: Can't pickle Task

11 views
Skip to first unread message

Django

unread,
Apr 24, 2026, 11:46:20 AMApr 24
to django-...@googlegroups.com
#37063: PicklingError: Can't pickle Task
--------------------------------+-----------------------------------------
Reporter: Johannes Maron | Type: Uncategorized
Status: new | Component: Tasks
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+-----------------------------------------
Hi there,

I am working on Django tasks executor and noticed that the current
implementation has a few oddities and bugs that we might want to address
in future releases.

For now, let's focus on the biggest one, Tasks, and therefore TasksResults
can't be pickled.
However, it is essential to use multiprocessing and to utilize the entire
CPU to execute tasks.

{{{
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "$HOME/.local/share/uv/python/cpython-3.14.0-macos-
aarch64-none/lib/python3.14/multiprocessing/reduction.py", line 51, in
dumps
cls(buf, protocol).dump(obj)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^
_pickle.PicklingError: Can't pickle <function cpu_heavy_task at
0x10986eae0>: it's not the same object as
tests.testapp.tasks.cpu_heavy_task
}}}

Of course, you can serialize and deserialize objects yourself, but that's
a pretty high bar to clear.
Especially since it's a fairly easy fix for Django.

Cheers!
Joe
--
Ticket URL: <https://code.djangoproject.com/ticket/37063>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 24, 2026, 11:54:13 AMApr 24
to django-...@googlegroups.com
#37063: PicklingError: Can't pickle Task
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: Uncategorized | Status: new
Component: Tasks | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Comment (by Johannes Maron):

Note: IMHO this also cannot be solved with subclassing Task or TaskResult.
--
Ticket URL: <https://code.djangoproject.com/ticket/37063#comment:1>

Django

unread,
Apr 24, 2026, 1:01:47 PMApr 24
to django-...@googlegroups.com
#37063: PicklingError: Can't pickle Task
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: New feature | Status: closed
Component: Tasks | Version: 6.0
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Jacob Walls):

* easy: 1 => 0
* resolution: => duplicate
* status: new => closed
* type: Uncategorized => New feature

Comment:

Hey Joe, this one is almost ready to merge, just would like a confirming
review from someone. Fancy a look?
[https://github.com/django/django/pull/20730 PR]

Duplicate of #36919
--
Ticket URL: <https://code.djangoproject.com/ticket/37063#comment:2>
Reply all
Reply to author
Forward
0 new messages