doc_process.py
550 Bytes
import time
import signal
from django.core.management import BaseCommand
class Command(BaseCommand):
def __init__(self):
super().__init__()
self.switch = True
signal.signal(signal.SIGTERM, self.signal_handler)
def signal_handler(self, sig, frame):
self.switch = False
print('get sig: {0}'.format(sig))
def handle(self, *args, **kwargs):
while self.switch:
print('process start')
time.sleep(5)
print('process success')
print('process stop')