#60 Can't unschedule a running task

closed-fixed
nobody
TaskKit (2)
5
2008-11-07
2003-11-26
Anonymous
No

If the TaskKit scheduler has a running task (i.e. a
task in the 'running' queue), 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 task's handle
object. unregisterTask only checks the scheduled and
ondemand queues.
You'd think 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 a TaskHandler
object, it sets the
value of _reregister and _rerun to 0 but, it doesn't
appear that the value of _reregister is ever checked
anywhere. It appears that the reschedule() method of
TaskHandler should check this value to determine an
appropriate return value.

3) When a running task that has been unregistered
completes 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 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()

Here's a simple example of how these issues interact
with one another:
- A user schedules a task that is subsequently
started; task object is in the running queue. While the
task is running, the user wants to modify the period of
the task. The following sequence of events occurs:
- Scheduler.addPeriodicAction is called with a new set
of parameters but with the same task name as the
running task.
- addPeriodicAction calls unregisterTask
- unregisterTask checks the scheduled and ondemand
queues and finds nothing so it installs what it thinks
is a new task in the scheduled queue.
- the original task finishes and is moved (with
original parameters) back to the scheduled queue,
overwriting the instance already in the scheduled queue.

This illustrates problem 1. Now assume the programmer
uses the technique described in 1 to unregister the
task in the running queue. You still encounter problem
2 and 3 and the end result is that the task in the
running queue still overwrites the task in the
scheduled queue.

Please review the attached patch which corrects issues
1, 2 & 3.

Brett Funderburg (brettf at deepfile dot com)

Discussion

  • Nobody/Anonymous

    Patch which allows unscheduling of a running task

     
  • Nobody/Anonymous

    Logged In: NO

    Ignore this patch. Two issues, I did discover side effects;
    and there is an extra colon (:) character in one line that
    breaks syntax correctness in python which causes the
    AppServer to not start.

    I will continue working on the problem.

     
  • Christoph Zwerschke

    After 5 years I have now finally fixed this in r7612. The bug report and patch were very helpful.

     
  • Christoph Zwerschke

    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks