make doc test run again - keep base.schedule.Scheduler

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2470 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-03-24 09:44:44 +00:00
parent a866d387ff
commit 8a6b84fe27
6 changed files with 6 additions and 25 deletions

View file

@ -4,6 +4,5 @@ $Id$
# register default adapters # register default adapters
#from cybertools.agent.base import agent, control, job, log, schedule from cybertools.agent.base import agent, control, job, log, schedule
from cybertools.agent.base import agent, control, job, log from cybertools.agent.core import schedule
from cybertools.agent.core import schedule

View file

@ -84,9 +84,6 @@ class Master(Agent):
class SampleAgent(Agent): class SampleAgent(Agent):
def __init__(self, parent):
self.parent = parent
def execute(self, job, params=None): def execute(self, job, params=None):
print 'Job %s on agent %s has been executed.' % (job.identifier, self.name) print 'Job %s on agent %s has been executed.' % (job.identifier, self.name)
self.log(job) self.log(job)
@ -95,6 +92,4 @@ class SampleAgent(Agent):
self.logger.log(dict(message='job execution', job=job.identifier, self.logger.log(dict(message='job execution', job=job.identifier,
agent=self.name)) agent=self.name))
agents.register(SampleAgent, Master, name='sample') agents.register(SampleAgent, Master, name='sample')

View file

@ -48,7 +48,6 @@ class Controller(object):
class SampleController(Controller): class SampleController(Controller):
def _getAgents(self): def _getAgents(self):
return [AgentSpecification('sample01', 'sample')] return [AgentSpecification('sample01', 'sample')]
@ -66,7 +65,6 @@ class AgentSpecification(object):
class JobSpecification(object): class JobSpecification(object):
startTime = None startTime = None

View file

@ -24,8 +24,7 @@ $Id$
from zope.interface import implements from zope.interface import implements
#from cybertools.agent.base.schedule import Scheduler from cybertools.agent.base.schedule import Scheduler
from cybertools.agent.core.schedule import Scheduler
from cybertools.agent.components import jobs from cybertools.agent.components import jobs
from cybertools.agent.interfaces import IScheduledJob from cybertools.agent.interfaces import IScheduledJob
@ -60,4 +59,3 @@ class Job(object):
newJob.successors = [s.copy() for s in self.successors] newJob.successors = [s.copy() for s in self.successors]
jobs.register(Job, Scheduler, name='sample') jobs.register(Job, Scheduler, name='sample')
#jobs.register(Job, Scheduler, name='BasicCrawler')

View file

@ -48,4 +48,3 @@ class Scheduler(object):
schedulers.register(Scheduler, Master, name='sample') schedulers.register(Scheduler, Master, name='sample')
#schedulers.register(Scheduler, Master, name='BasicCrawler')

View file

@ -19,7 +19,7 @@
""" """
Basic (sample) job scheduler. Basic (sample) job scheduler.
$Id: schedule.py 2415 2008-02-24 15:04:13Z helmutm $ $Id$
""" """
from time import time from time import time
@ -47,24 +47,16 @@ class Scheduler(object):
self.queue.append(job) self.queue.append(job)
if startTime is None: if startTime is None:
startTime = int(time()) startTime = int(time())
if startTime < int(time()):
'''
Only small test for first draft
'''
startTime = startTime + int(time())
job.startTime = startTime job.startTime = startTime
job.scheduler = self job.scheduler = self
#while startTime in self.queue: #while startTime in self.queue:
# startTime += 1 # startTime += 1
#self.queue[startTime] = job #self.queue[startTime] = job
#reactor.callLater(startTime-int(time()), job.execute) reactor.callLater(startTime-int(time()), job.execute)
job.execute() job.execute()
return startTime return startTime
def getJobsToExecute(startTime=0): def getJobsToExecute(startTime=0):
return [j for j in self.queue.values() if startTime <= j.startTime] return [j for j in self.queue.values() if startTime <= j.startTime]
schedulers.register(Scheduler, Master, name='core')
schedulers.register(Scheduler, Master, name='sample')
#schedulers.register(Scheduler, Master, name='BasicCrawler')