From 01257f65a6f262df953f63fafb45993ddf4b7df8 Mon Sep 17 00:00:00 2001 From: GaryO Date: Mon, 18 Jun 2018 18:16:10 -0400 Subject: [PATCH 1/2] Make auto reloader work on Mac (#1249) --- sanic/reloader_helpers.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/sanic/reloader_helpers.py b/sanic/reloader_helpers.py index e1349089..73759124 100644 --- a/sanic/reloader_helpers.py +++ b/sanic/reloader_helpers.py @@ -55,9 +55,9 @@ def restart_with_reloader(): def kill_process_children_unix(pid): - """Find and kill child process of a process (maximum two level). + """Find and kill child processes of a process (maximum two level). - :param pid: PID of process (process ID) + :param pid: PID of parent process (process ID) :return: Nothing """ root_process_path = "/proc/{pid}/task/{pid}/children".format(pid=pid) @@ -77,13 +77,36 @@ def kill_process_children_unix(pid): os.kill(int(_pid), signal.SIGTERM) +def kill_process_children_osx(pid): + """Find and kill child processes of a process. + + :param pid: PID of parent process (process ID) + :return: Nothing + """ + subprocess.run(['pkill', '-P', str(pid)]) + + +def kill_process_children(pid): + """Find and kill child processes of a process. + + :param pid: PID of parent process (process ID) + :return: Nothing + """ + if sys.platform == 'darwin': + kill_process_children_osx(pid) + elif sys.platform == 'posix': + kill_process_children_unix(pid) + else: + pass # should signal error here + + def kill_program_completly(proc): """Kill worker and it's child processes and exit. :param proc: worker process (process ID) :return: Nothing """ - kill_process_children_unix(proc.pid) + kill_process_children(proc.pid) proc.terminate() os._exit(0) @@ -112,7 +135,7 @@ def watchdog(sleep_interval): mtimes[filename] = mtime continue elif mtime > old_time: - kill_process_children_unix(worker_process.pid) + kill_process_children(worker_process.pid) worker_process = restart_with_reloader() mtimes[filename] = mtime From 9092ee9f0e65d38a65ac1d506af65d06e5f86652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnulfo=20Sol=C3=ADs?= Date: Wed, 27 Jun 2018 07:25:25 +0200 Subject: [PATCH 2/2] HTTP Entity Headers (#1127) * introduced basic entity and hopbyhop header identification * removed entity headers * coding style fixes * remove unneeded header check * moved from bytes to unicode in headers * changed list to tuple in empty response statuses --- sanic/exceptions.py | 2 +- sanic/http.py | 128 +++++++++++++++++++++++++++++++++++++++++ sanic/response.py | 81 ++++---------------------- tests/test_response.py | 10 ++-- 4 files changed, 145 insertions(+), 76 deletions(-) create mode 100644 sanic/http.py diff --git a/sanic/exceptions.py b/sanic/exceptions.py index 6da747f2..25dbd47d 100644 --- a/sanic/exceptions.py +++ b/sanic/exceptions.py @@ -1,4 +1,4 @@ -from sanic.response import STATUS_CODES +from sanic.http import STATUS_CODES TRACEBACK_STYLE = '''