瀏覽代碼

Now works on Windows. Closes celery/kombu#133

Ask Solem 12 年之前
父節點
當前提交
8cf06041bd
共有 2 個文件被更改,包括 15 次插入2 次删除
  1. 5 1
      celery/task/trace.py
  2. 10 1
      celery/worker/__init__.py

+ 5 - 1
celery/task/trace.py

@@ -49,7 +49,11 @@ RETRY = states.RETRY
 FAILURE = states.FAILURE
 EXCEPTION_STATES = states.EXCEPTION_STATES
 
-_tasks = default_app._tasks
+try:
+    _tasks = default_app._tasks
+except AttributeError:
+    # Windows: will be set later by concurrency.processes.
+    pass
 
 
 def mro_lookup(cls, attr, stop=()):

+ 10 - 1
celery/worker/__init__.py

@@ -320,7 +320,16 @@ class WorkController(configurated):
         self.pidfile = pidfile
         self.pidlock = None
         self.use_eventloop = (detect_environment() == "default" and
-                              self.app.broker_connection().is_evented)
+                              self.app.broker_connection().is_evented and
+                              not self.app.IS_WINDOWS)
+
+        # Update celery_include to have all known task modules, so that we
+        # ensure all task modules are imported in case an execv happens.
+        task_modules = set(task.__class__.__module__
+                            for task in self.app.tasks.itervalues())
+        self.app.conf.CELERY_INCLUDE = (
+            set(self.app.conf.CELERY_INCLUDE) + set(task_modules),
+        )
 
         # Initialize boot steps
         self.pool_cls = _concurrency.get_implementation(self.pool_cls)