I need another pair of eyes to look at something I've been trying to
figure out. It appears that if TaskKit has a running task, there is no way
to remove that task from the Scheduler. There seem to be some subtle
reasons for this.

1) In TaskKit/Scheduler.py - unregisterTask(), the method never checks if
the task is in the running queue so it can call unregister() on the handle
object. The unregisterTask() method only checks the scheduled and ondemand
queues.
You'd think that the following code:

tm = app.taskManager()
t = tm.running("mytask")
if t:
   t.unregister()

would work around this problem, but...

2) when unregister() is called on any TaskHandler object, it sets the
value of _reregister and _rerun to 0. However, it doesn't appear to me
that _reregister is ever used anywhere. It appears that the reschedule()
method of TaskHandler should check this value to determine an appropriate
return code.

3) When the task does complete and the Scheduler object's
notifyCompletion() method is called, it doesn't look like it is calling
handle.reschedule() in the correct place. What ends up happening is that a
scheduled task is always returned back to the scheduled queue with the
original task parameters even though it should be discarded after
completion - by virtue of the method call to unregister()

The attached patch corrects issues 2 & 3 in my testing but I need someone
to review it for correctness since I don't know if there are any
unintended side-effects. Also, please provide insight on whether issue 1
is a problem or not.


diff -u -r Webware-0.8.1.orig/TaskKit/Scheduler.py
Webware-0.8.1/TaskKit/Scheduler.py
--- Webware-0.8.1.orig/TaskKit/Scheduler.py 2003-10-15 16:22:29.000000000
+0000
+++ Webware-0.8.1/TaskKit/Scheduler.py  2003-10-15 20:53:03.000000000 +0000
@@ -393,15 +393,15 @@
        name = handle.name()
        if self.hasRunning(name):
            self.delRunning(name)
-           if handle.startTime() and handle.startTime() > time():
-               self.scheduleTask(handle)
-           else:
-               if handle.reschedule():
+           if handle.reschedule():
+               if handle.startTime() and handle.startTime() > time():
                    self.scheduleTask(handle)
-               elif not handle.startTime():
-                   self.setOnDemand(handle)
-                   if handle.runAgain():
-                       self.runTask(handle)
+               else:
+                    self.scheduleTask(handle)
+                   if not handle.startTime():
+                       self.setOnDemand(handle)
+                       if handle.runAgain():
+                           self.runTask(handle)

    def notify(self):
        self._notifyEvent.set()
diff -u -r Webware-0.8.1.orig/TaskKit/TaskHandler.py
Webware-0.8.1/TaskKit/TaskHandler.py
--- Webware-0.8.1.orig/TaskKit/TaskHandler.py   2003-10-15
16:22:29.000000000 +0000
+++ Webware-0.8.1/TaskKit/TaskHandler.py    2003-10-15 20:18:00.000000000
+0000
@@ -53,7 +53,9 @@
        Method to determine whether this task should be rescheduled.
Increments the
        startTime and returns true if this is a periodically executed task.
        """
-       if self._period == 0:
+       if self._reregister == 0:
+           return 0
+       elif self._period == 0:
            return 0
        else:
            if self._lastTime - self._startTime > self._period:  #if the
time taken to run the task exceeds the period

Thanks for looking at this.

brett




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Webware-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to