Run a worker task immediately when it starts.
This commit is contained in:
parent
9b3f61e410
commit
58dbb540a1
1 changed files with 5 additions and 1 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue