소스 검색

Makes events.state.State pickleable

Mher Movsisyan 12 년 전
부모
커밋
050919f896
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  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()