aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2013-06-06 14:37:48 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2013-06-06 14:37:48 -0400
commitac855bb61b898c924a9c27e0ebfc68e371d426cd (patch)
treef4870a3f5923b5eabbcbab3f05b229862d150018
parent399ba4b01db11319aedfee6f4214e995959d8a07 (diff)
downloadipsutils-ac855bb61b898c924a9c27e0ebfc68e371d426cd.tar.gz
Task controller now has an "atexit" callback in case the program exits prematurely
-rw-r--r--ipsutils/task.py6
1 files changed, 5 insertions, 1 deletions
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):