Browse Source

Refactores event states to allow pickling

Conflicts:
	celery/events/state.py
Mher Movsisyan 12 years ago
parent
commit
979aa9468f
1 changed files with 2 additions and 4 deletions
  1. 2 4
      celery/events/state.py

+ 2 - 4
celery/events/state.py

@@ -214,8 +214,6 @@ class State(object):
         self.workers = LRUCache(limit=max_workers_in_memory)
         self.tasks = LRUCache(limit=max_tasks_in_memory)
         self.event_callback = callback
-        self.group_handlers = {'worker': self.worker_event,
-                               'task': self.task_event}
         self._mutex = threading.Lock()
 
     def freeze_while(self, fun, *args, **kwargs):
@@ -300,8 +298,8 @@ class State(object):
     def _dispatch_event(self, event):
         self.event_count += 1
         event = kwdict(event)
-        group, _, type = event.pop('type').partition('-')
-        self.group_handlers[group](type, event)
+        group, _, subject = event.pop('type').partition('-')
+        getattr(self, group + '_event')(subject, event)
         if self.event_callback:
             self.event_callback(self, event)