--- a/src/pyams_scheduler/process.py Thu Jan 10 17:12:55 2019 +0100
+++ b/src/pyams_scheduler/process.py Thu Jan 10 17:14:14 2019 +0100
@@ -12,33 +12,39 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
import logging
-logger = logging.getLogger('PyAMS (scheduler)')
-
from datetime import datetime
from threading import Thread
-# import interfaces
-from pyams_scheduler.interfaces import SCHEDULER_NAME
-from pyams_utils.interfaces import PYAMS_APPLICATION_SETTINGS_KEY, PYAMS_APPLICATION_DEFAULT_NAME
-
-# import packages
from apscheduler.jobstores.memory import MemoryJobStore
from apscheduler.schedulers.background import BackgroundScheduler
+from zope.interface import implementer
+
+from pyams_scheduler.interfaces import ISchedulerProcess, SCHEDULER_NAME, ITask
from pyams_scheduler.task import ImmediateTaskTrigger
+from pyams_utils.interfaces import PYAMS_APPLICATION_DEFAULT_NAME, PYAMS_APPLICATION_SETTINGS_KEY
from pyams_utils.zodb import ZODBConnection
from pyams_zmq.handler import ZMQMessageHandler
from pyams_zmq.process import ZMQProcess
+logger = logging.getLogger('PyAMS (scheduler)')
+
+
class BaseTaskThread(Thread):
def __init__(self, process, settings):
Thread.__init__(self)
self.process = process
- self.settings = settings
+ if ITask.providedBy(settings):
+ scheduler = settings.__parent__
+ self.settings = {
+ 'zodb_name': scheduler.zodb_name,
+ 'task_name': settings.__name__,
+ 'job_id': settings.internal_id
+ }
+ else:
+ self.settings = settings
def _get_connection(self):
zodb_name = self.settings.get('zodb_name')
@@ -203,6 +209,7 @@
handler = SchedulerHandler
+@implementer(ISchedulerProcess)
class SchedulerProcess(ZMQProcess):
"""ØMQ tasks scheduler process"""