Selaa lähdekoodia

Makes events.state.State pickleable

Mher Movsisyan 12 vuotta sitten
vanhempi
commit
050919f896
1 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  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()