|
@@ -4,6 +4,7 @@ Worker Controller Threads
|
|
|
|
|
|
"""
|
|
"""
|
|
import threading
|
|
import threading
|
|
|
|
+import traceback
|
|
from Queue import Empty as QueueEmpty
|
|
from Queue import Empty as QueueEmpty
|
|
|
|
|
|
from celery.app import app_or_default
|
|
from celery.app import app_or_default
|
|
@@ -33,6 +34,7 @@ class Mediator(threading.Thread):
|
|
self._shutdown = threading.Event()
|
|
self._shutdown = threading.Event()
|
|
self._stopped = threading.Event()
|
|
self._stopped = threading.Event()
|
|
self.setDaemon(True)
|
|
self.setDaemon(True)
|
|
|
|
+ self.setName(self.__class__.__name__)
|
|
|
|
|
|
def move(self):
|
|
def move(self):
|
|
try:
|
|
try:
|
|
@@ -47,7 +49,14 @@ class Mediator(threading.Thread):
|
|
self.logger.debug(
|
|
self.logger.debug(
|
|
"Mediator: Running callback for task: %s[%s]" % (
|
|
"Mediator: Running callback for task: %s[%s]" % (
|
|
task.task_name, task.task_id))
|
|
task.task_name, task.task_id))
|
|
- self.callback(task) # execute
|
|
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ self.callback(task)
|
|
|
|
+ except Exception, exc:
|
|
|
|
+ self.logger.error("Mediator callback raised exception %r\n%s" % (
|
|
|
|
+ exc, traceback.format_exc()))
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
def run(self):
|
|
def run(self):
|
|
while not self._shutdown.isSet():
|
|
while not self._shutdown.isSet():
|