Run a worker task immediately when it starts.

This commit is contained in:
jakedt 2014-04-22 13:55:54 -04:00
parent 9b3f61e410
commit 58dbb540a1

View file

@ -4,6 +4,7 @@ import signal
from threading import Event
from apscheduler.scheduler import Scheduler
from datetime import datetime, timedelta
logger = logging.getLogger(__name__)
@ -49,8 +50,11 @@ class Worker(object):
def start(self):
logger.debug("Scheduling worker.")
soon = datetime.now() + timedelta(seconds=.001)
self._sched.start()
self._sched.add_interval_job(self.poll_queue, seconds=self._poll_period_seconds)
self._sched.add_interval_job(self.poll_queue, seconds=self._poll_period_seconds,
start_date=soon)
self._sched.add_interval_job(self.watchdog, seconds=self._watchdog_period_seconds)
signal.signal(signal.SIGTERM, self.join)