Add test for auto reloading.

This commit is contained in:
Yaser Amiri
2017-12-07 20:19:40 +03:30
parent 52c2a8484e
commit 3fe3c2c79f
4 changed files with 91 additions and 5 deletions

View File

@@ -646,7 +646,7 @@ class Sanic:
self.is_running = True
if workers == 1:
if os.name == 'posix' and auto_reload and \
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
reloader_helpers.watchdog(2)
else:
serve(**server_settings)
@@ -808,7 +808,7 @@ class Sanic:
logger.setLevel(logging.DEBUG)
if self.config.LOGO is not None and \
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
os.environ.get('MAIN_PROCESS_RUNNED') != 'true':
logger.debug(self.config.LOGO)
if run_async:

View File

@@ -58,10 +58,10 @@ def kill_process_children_unix(pid):
:param pid: PID of process (process ID)
:return: Nothing
"""
root_proc_path = "/proc/%s/task/%s/children" % (pid, pid)
if not os.path.isfile(root_proc_path):
root_process_path = "/proc/%s/task/%s/children" % (pid, pid)
if not os.path.isfile(root_process_path):
return
with open(root_proc_path) as children_list_file:
with open(root_process_path) as children_list_file:
children_list_pid = children_list_file.read().split()
for child_pid in children_list_pid: