From c6980e85c7d8ed08db0c3a9a084b577683c6794f Mon Sep 17 00:00:00 2001 From: helmutm Date: Tue, 14 Aug 2007 08:31:01 +0000 Subject: [PATCH] Job: + whenStarted, whenFinished callbacks, now with additional job argument; let Scheduler.schedule() return the real startTime (may be used as jobId) git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1917 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/README.txt | 5 +++++ agent/interfaces.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/agent/README.txt b/agent/README.txt index fa08789..092857a 100644 --- a/agent/README.txt +++ b/agent/README.txt @@ -129,6 +129,7 @@ How does this work? ------------------- >>> from time import time + >>> from loops.agent.schedule import Job >>> class TestJob(Job): ... def execute(self): @@ -137,6 +138,10 @@ How does this work? ... return d >>> scheduler = agent.scheduler + +The ``schedule()`` method accepts the start time as a second argument, +if not present use the current time, i.e. start the job immediately. + >>> startTime = scheduler.schedule(TestJob()) >>> tester.iterate() diff --git a/agent/interfaces.py b/agent/interfaces.py index e34d03e..462b097 100644 --- a/agent/interfaces.py +++ b/agent/interfaces.py @@ -43,9 +43,14 @@ class IScheduler(Interface): logger = Attribute('Logger instance to be used for recording ' 'job execution and execution results.') - def schedule(job, startTime): + def schedule(job, startTime=None): """ Register the job given for execution at the intended start - date/time and return the job. + date/time (an integer timestamp) and return the job. + + If the start time is not given schedulethe job for immediate + start. Return the start time with which the job has been + scheduled - this may be different from the start time + supplied. """ def getJobsToExecute(startTime=None):