From ac855bb61b898c924a9c27e0ebfc68e371d426cd Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 6 Jun 2013 14:37:48 -0400 Subject: Task controller now has an "atexit" callback in case the program exits prematurely --- ipsutils/task.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ipsutils/task.py') diff --git a/ipsutils/task.py b/ipsutils/task.py index 9ae4d7e..2c1ccec 100644 --- a/ipsutils/task.py +++ b/ipsutils/task.py @@ -29,7 +29,7 @@ class Controller(object): """ self.stack.append(t) - def do_tasks(self): + def do_tasks(self, atexit=None): """ FILO execution of tasks """ if not self.stack: @@ -40,11 +40,15 @@ class Controller(object): if type(status) == type(True): if not status: print("Internal error: {}".format(status)) + if atexit is not None: + atexit() exit(status) else: if status is not 0 \ and status is not None: print("exit: {}".format(status)) + if atexit is not None: + atexit() exit(status) class Task(object): -- cgit