Fix auto_reload in Linux (#1286)
* Fix two problems with the auto_reloader in Linux. 1) Change 'posix' to 'linux' in sys.plaform check, because 'posix' is an invalid value and 'linux' is the correct value to use here. 2) In kill_process_children, don't just kill the 2nd level procs, also kill the 1st level procs. Also in kill_process_children, catch and ignore errors in the case that the child proc is already killed. * Fix flake8 formatting on PR
This commit is contained in:
parent
1814ff05f4
commit
79e35bbdf6
|
@ -74,7 +74,14 @@ def kill_process_children_unix(pid):
|
|||
with open(children_proc_path) as children_list_file_2:
|
||||
children_list_pid_2 = children_list_file_2.read().split()
|
||||
for _pid in children_list_pid_2:
|
||||
os.kill(int(_pid), signal.SIGTERM)
|
||||
try:
|
||||
os.kill(int(_pid), signal.SIGTERM)
|
||||
except ProcessLookupError:
|
||||
continue
|
||||
try:
|
||||
os.kill(int(child_pid), signal.SIGTERM)
|
||||
except ProcessLookupError:
|
||||
continue
|
||||
|
||||
|
||||
def kill_process_children_osx(pid):
|
||||
|
@ -94,7 +101,7 @@ def kill_process_children(pid):
|
|||
"""
|
||||
if sys.platform == 'darwin':
|
||||
kill_process_children_osx(pid)
|
||||
elif sys.platform == 'posix':
|
||||
elif sys.platform == 'linux':
|
||||
kill_process_children_unix(pid)
|
||||
else:
|
||||
pass # should signal error here
|
||||
|
@ -136,8 +143,8 @@ def watchdog(sleep_interval):
|
|||
continue
|
||||
elif mtime > old_time:
|
||||
kill_process_children(worker_process.pid)
|
||||
worker_process.terminate()
|
||||
worker_process = restart_with_reloader()
|
||||
|
||||
mtimes[filename] = mtime
|
||||
break
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user