Browse Source

Eventlet: on_accepted needs pid and time_start arguments

Ask Solem 14 years ago
parent
commit
1172fb2464
2 changed files with 13 additions and 5 deletions
  1. 4 2
      celery/concurrency/base.py
  2. 9 3
      celery/concurrency/evlet.py

+ 4 - 2
celery/concurrency/base.py

@@ -1,4 +1,6 @@
+import os
 import sys
+import time
 import traceback
 
 from celery import log
@@ -8,9 +10,9 @@ from celery.utils import timer2
 
 
 def apply_target(target, args=(), kwargs={}, callback=None,
-        accept_callback=None):
+        accept_callback=None, pid=None):
     if accept_callback:
-        accept_callback()
+        accept_callback(pid or os.getpid(), time.time())
     callback(target(*args, **kwargs))
 
 

+ 9 - 3
celery/concurrency/evlet.py

@@ -11,13 +11,19 @@ if not os.environ.get("EVENTLET_NOPATCH"):
     eventlet.debug.hub_prevent_multiple_readers(False)
 
 from eventlet import GreenPool
-from eventlet.greenthread import spawn, spawn_after_local
+from eventlet.greenthread import getcurrent, spawn, spawn_after_local
 from greenlet import GreenletExit
 
-from celery.concurrency.base import apply_target, BasePool
+from celery.concurrency import base
 from celery.utils import timer2
 
 
+def apply_target(target, args=(), kwargs={}, callback=None,
+                 accept_callback=None):
+    return base.apply_target(target, args, kwargs, callback, accept_callback,
+                             pid=getcurrent())
+
+
 class Schedule(timer2.Schedule):
 
     def __init__(self, *args, **kwargs):
@@ -82,7 +88,7 @@ class Timer(timer2.Timer):
         pass
 
 
-class TaskPool(BasePool):
+class TaskPool(base.BasePool):
     Pool = GreenPool
     Timer = Timer