﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17776	DoesNotExist is not picklable	Łukasz Langa	nobody	"{{{
>>> import django
>>> django.contrib.auth.models.User.DoesNotExist
<class 'django.contrib.auth.models.DoesNotExist'>
>>> import pickle
>>> pickle.dumps(django.contrib.auth.models.User.DoesNotExist())
Traceback (most recent call last):
...
PicklingError: Can't pickle <class 'django.contrib.auth.models.DoesNotExist'>: it's not found as django.contrib.auth.models.DoesNotExist
}}}

The example uses {{{contrib.auth.models.User}}} but this is true for all models AFAICT.

The reason why picklability of this class is important is for multiprocessing exception handling, for instance in Celery tasks. Now every other exception in Celery gets a nice traceback in the logs but for DoesNotExist exceptions it's a useless:

{{{
Traceback (most recent call last):
 File ""/home/virtualenv/lib/python2.7/site-packages/celery/concurrency/processes/pool.py"", line 199, in worker
   put((READY, (job, i, result)))
 File ""/usr/lib/python2.7/multiprocessing/queues.py"", line 392, in put
   return send(obj)
MaybeEncodingError: Error sending result: '<ExceptionInfo: ObjectDoesNotExist('LeagueMember matching query does not exist.',)>'. Reason: 'Can't pickle <class 'psl.league.models.DoesNotExist'>: attribute lookup psl.league.models.DoesNotExist failed'.
}}}"	Bug	closed	Database layer (models, ORM)	1.3	Normal	fixed			Accepted	0	0	0	0	0	0
