[TransWarp] scheduling bug or my fault?

Matthias Drochner M.Drochner at fz-juelich.de
Mon Aug 18 14:46:36 EDT 2003


Just tried to find out how get a mix of background and interactive
tasks, and found that an AdaptiveTask is scheduled in a very uneven
way: in my appended test program, invocations happen pairwise, two
calls close together, followed by the intended 10s delay.
Is there a bug or am I doing something wrong?

best regards
Matthias

from __future__ import generators

from peak.api import *
from peak.running.commands import EventDriven
from peak.running.daemons import AdaptiveTask

def taskiter(num):
        tasks = ["item%d" % i for i in range(num)]
        return iter(tasks)

class mytask(AdaptiveTask):
        runEvery =10

        def init(self, num):
                self.tasks = taskiter(num)

        def getWork(self):
                print "getwork"
                try:
                        return self.tasks.next()
                except StopIteration:
                        return None

        def doWork(self, job):
                print "dowork", job
                return 1

class myml(EventDriven):
        reactor = binding.bindTo(running.IBasicReactor)
        tq = binding.bindTo(running.ITaskQueue)
        task = binding.New(mytask)

        def init(self):
                self.task.init(5)
                self.tq.addTask(self.task)

ml = myml(config.makeRoot())
ml.init()
ml.run()





More information about the PEAK mailing list