Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pyrem/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import random
import string
import signal
import sys

from enum import Enum
Expand Down Expand Up @@ -43,6 +44,13 @@ def cleanup():
(task, exc[0], exc[1], exc[2]))
continue

def sigterm_handler(_sig, _frame):
sys.exit(0)

# Register a SIGTERM handler if one is not already registered.
# By catching the signal atexit can do its thing in the case of SIGTERM.
if not signal.getsignal(signal.SIGTERM):
signal.signal(signal.SIGTERM, sigterm_handler)

# TODO: create a wait_stopped() so that Tasks can be stopped in parallel

Expand Down