Created
July 9, 2018 13:06
-
-
Save AlexDemian/6ef7f0e55e1f553b10df3258b2583dba to your computer and use it in GitHub Desktop.
Revisions
-
AlexDemian created this gist
Jul 9, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import subprocess import os import signal import time path = os.path.abspath(__file__).rpartition('/')[0] child_comm = ['python %s/child.py' % path] parent_comm = ['python %s/parent.py' % path] proc = subprocess.Popen(child_comm, shell=True) print 'New child process created' your_condition = True while your_condition: time.sleep(1) subprocess.Popen(parent_comm, shell=True, preexec_fn=os.setpgrp) print 'New wrapper(parent process) created' print 'Terminating old processgroup...' os.killpg(os.getpgid(proc.pid), signal.SIGTERM)