aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fixtures/project_with_tasks_that_handle_interrupts
diff options
context:
space:
mode:
authorRobinFrcd <29704178+RobinFrcd@users.noreply.github.com>2020-08-08 00:52:47 +0200
committerGitHub <noreply@github.com>2020-08-08 01:52:47 +0300
commit3a0362a6028b949016cd2a67bbeeab9b8d8bf50c (patch)
tree28be91f83e270b4ff461c39cef3047e68cd778bc /tests/fixtures/project_with_tasks_that_handle_interrupts
parentdocs: add eugenetriguba as a contributor (#17) (diff)
downloadtaskipy2-3a0362a6028b949016cd2a67bbeeab9b8d8bf50c.zip
Propagate SIGTERM to child processes (#19)
SIGTERM sent to taskipy are handed over to task subprocess
Diffstat (limited to 'tests/fixtures/project_with_tasks_that_handle_interrupts')
-rw-r--r--tests/fixtures/project_with_tasks_that_handle_interrupts/loop_with_sigint_handler.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/fixtures/project_with_tasks_that_handle_interrupts/loop_with_sigint_handler.py b/tests/fixtures/project_with_tasks_that_handle_interrupts/loop_with_sigint_handler.py
index 80f7b23..50ed139 100644
--- a/tests/fixtures/project_with_tasks_that_handle_interrupts/loop_with_sigint_handler.py
+++ b/tests/fixtures/project_with_tasks_that_handle_interrupts/loop_with_sigint_handler.py
@@ -1,11 +1,21 @@
+import signal
+import sys
import time
+
def main():
try:
while True:
- time.sleep(.1)
+ time.sleep(0.1)
except KeyboardInterrupt:
print('failing gracefully...')
+
+def sigterm_handler(sig, frame):
+ print('Shutdown gracefully with sigterm...')
+ sys.exit(123)
+
+
if __name__ == '__main__':
+ signal.signal(signal.SIGTERM, sigterm_handler)
main()