Dan Kenigsberg has submitted this change and it was merged.
Change subject: task: add the support for abort_callback ......................................................................
task: add the support for abort_callback
This patch adds the support for defining a callback used to abort a long running task, e.g.:
long_operation = MyLongOperation()
def abort_long_operation(): long_operation.terminate()
# abort_callback registers the callback for the time # of execution of the code block with vars.task.abort_callback(abort_long_operation): long_operation.execute()
When another thread (e.g. an external xml-rpc request) tries to abort the task (calling "stop"), the registered callbacks will be called.
This patch defines the basic infrastructure to register abort functions for long running operations, the technology used to actually implement the interruption is left to the user.
Change-Id: Ib82289e28e5ad9ea142850c31ccff3366b8397dc Signed-off-by: Federico Simoncelli fsimonce@redhat.com Reviewed-on: https://gerrit.ovirt.org/33689 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Dan Kenigsberg danken@redhat.com Tested-by: Dan Kenigsberg danken@redhat.com --- M vdsm/storage/task.py 1 file changed, 33 insertions(+), 1 deletion(-)
Approvals: Dan Kenigsberg: Verified; Looks good to me, approved; Passed CI tests