Explorar o código

Makes events.state.State pickleable

Mher Movsisyan %!s(int64=12) %!d(string=hai) anos
pai
achega
050919f896
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      celery/events/state.py

+ 9 - 0
celery/events/state.py

@@ -445,5 +445,14 @@ class State(object):
         return '<State: events={0.event_count} tasks={0.task_count}>' \
             .format(self)
 
+    def __getstate__(self):
+        d = dict(vars(self))
+        d.pop('_mutex')
+        return d
+
+    def __setstate__(self, state):
+        self.__dict__ = state
+        self._mutex = threading.Lock()
+
 
 state = State()