A task that relies on a scheduler for ongoing execution
Scheduled tasks do not run when their step() methods are called, but
instead simply put themselves on the scheduler's schedule for later
execution. This means that scheduled tasks do not run during operations
that cause callbacks, and so they cannot raise errors in apparently-unrelated
code. They also are less likely to cause unintended or unexpected
side-effects due to their executing between yield statements in other
tasks. And finally, scheduled tasks can reliably signal that they
were aborted due to an uncaught exception, via their aborted attribute.
There are some drawbacks, however. First, scheduled tasks require a
scheduler, and the scheduler must tick() repeatedly as long as one wishes
the tasks to continue running. Second, scheduled tasks can take
slightly longer to task switch than unscheduled ones, because multiple
callbacks are required.
Last, but far from least, when a scheduled task is resumed, it cannot be
guaranteed that another task or callback has not already contravened
whatever condition the task was waiting for. This is true even if only
one task is waiting for that condition, since non-task callbacks or
other code may be executed between the triggering of the event, and the
time at which the task's resumption is scheduled.
Methods
|
|
step
|
|
step
|
step ( source=None, event=NOT_GIVEN )
Schedule task to resume during its scheduler's next tick()
|
|