Skip to content

TaskExecutor: add an API to stop / cancel current processing

payno requested to merge add_stop_current_task into main

Details

Provide API to cancel a task. Related to ewokscore!217 (merged)

!!! this PR only handle the OWEwoksWidgetOneThread use case (darfix one). !!! Others use cases will be tackle later. But the proposed API is:

  • cancel_current_task() -> cancel the on-going task.
  • cancel_task(*args, **kwargs) -> cancel a task either on going or stored in a stack
API / widget OWEwoksWidgetNoThread OWEwoksWidgetOneThread OWEwoksWidgetOneThreadPerRun OWEwoksWidgetWithTaskStack
cancel_current_task
cancel_task

Note 1: OWEwoksWidgetNoThread and OWEwoksWidgetOneThread have no need for cancel_task because this is either on-going or the execution has been refused

Note 2: OWEwoksWidgetOneThreadPerRun has no cancel_current_task because it created one thread per run. So there is no one task running but n task running. So for this one 'cancel_task' makes more sense.

The cancel cancel_task needs to have a way to identify a task when submitted. Here are some options (to be discussed / handle later):

  • provide a task index when submitted (unique identifier)
  • store inputs in order of the task instances in order to find them back.
Edited by payno

Merge request reports