mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-10 20:10:56 +08:00
Initial work on fix for #424 - TypeError: can't pickle _thread.lock objects.
Made `Broker` and `Queue` classes pickable which fixes the the problem with new default `spawn` proces start method.
This commit is contained in:
+7
-1
@@ -54,9 +54,15 @@ class Queue(multiprocessing.queues.Queue):
|
||||
super(Queue, self).__init__(
|
||||
*args, ctx=multiprocessing.get_context(), **kwargs
|
||||
)
|
||||
|
||||
self.size = SharedCounter(0)
|
||||
|
||||
def __getstate__(self):
|
||||
return super(Queue, self).__getstate__() + (self.size, )
|
||||
|
||||
def __setstate__(self, state):
|
||||
super(Queue, self).__setstate__(state[:-1])
|
||||
self.size = state[-1]
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
super(Queue, self).put(*args, **kwargs)
|
||||
self.size.increment(1)
|
||||
|
||||
Reference in New Issue
Block a user