import signal
import os
import time
def shutdown():
with open('/var/run/myscipt.pid') as f:
pid = int(f.read())
print('Terminating process with pid %d' % pid)
os.kill(pid, signal.SIGTERM)
if __name__ == '__main__':
shutdown()
import signal
import sys
import time
import signal
import os
def signal_handler(signum, frame):
print('exiting')
sys.exit(0)
signal.signal(signal.SIGTERM, signal_handler)
with open('/var/run/myscipt.pid', 'w') as f:
f.write(str(os.getpid()))
while True:
print('ok')
time.sleep(1)
signal.SIGTERM
os.kill(<тут пид процесса>, signal.SIGTERM)
либо your_child_process.send_signal(signal.SIGTERM)
when using a module such as multiprocessing or a forking web deploy method such as FastCGI make sure to create the connections after the fork.
https://stackoverflow.com/questions/11287402/how-t...
А сколько у тебя ушло на написание вопроса?