[Kimchi-devel] [PATCH V2] [Wok 0/2] Issue #122 - Make AsyncTask stoppable.

pvital at linux.vnet.ibm.com pvital at linux.vnet.ibm.com
Wed Aug 31 18:13:04 UTC 2016


From: Paulo Vital <pvital at linux.vnet.ibm.com>

v2:
	- Modified exception code used
	- Updated i18n messages

V1:

This patch-set gives to user a way to 'stop' a Task that is still running by
setting the Task status to "killed".

Since an AsyncTask is basic a thread running in the system and this thread can
execute a pure Python method or a background command (by using run_command()
from wok.utils), the developer must pass to AsyncTask constructor a method to be
executed by the DELETE operation, called here as 'kill_cb'.

If none kill_cb is passed, the task will not be able to stopped and an error
message will be raised to user if DELETE operation is executed. Otherwise, the
kill_cb method will be executed by kill() method (responsible to execute the
DELETE operation) of AsyncTask class and its status set to 'killed'.

The unit tests present how you can use it.

Paulo Vital (2):
  Issue #122 - Make AsyncTask stoppable.
  Issue #122 - Add unit test to stop AsyncTask.

 docs/API/tasks.md      |  2 ++
 src/wok/asynctask.py   | 18 +++++++++++++++++-
 src/wok/i18n.py        |  2 ++
 src/wok/model/tasks.py | 13 +++++++++++++
 tests/test_api.py      | 26 ++++++++++++++++++++++++--
 tests/test_tasks.py    | 19 ++++++++++++++++++-
 6 files changed, 76 insertions(+), 4 deletions(-)

-- 
2.7.4




More information about the Kimchi-devel mailing list