From 5dcfdf28b0e9ec93a526b88d3820d79d62723204 Mon Sep 17 00:00:00 2001 From: Sanskar Jethi Date: Mon, 3 Apr 2023 21:14:55 +0100 Subject: [PATCH] Release v0.26.1 --- integration_tests/base_routes.py | 2 ++ pyproject.toml | 1 - requirements.txt | 1 - robyn/__init__.py | 2 +- robyn/reloader.py | 14 +++++++------- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/integration_tests/base_routes.py b/integration_tests/base_routes.py index 78732edf9..d78e8d341 100644 --- a/integration_tests/base_routes.py +++ b/integration_tests/base_routes.py @@ -1,4 +1,6 @@ import os + + import pathlib from robyn import WS, Robyn, Request, Response, jsonify, serve_file, serve_html diff --git a/pyproject.toml b/pyproject.toml index 7bbe90a5e..c8b3891ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ name = "robyn" dependencies = [ 'watchdog == 2.2.1', 'multiprocess == 0.70.14', - 'psutil == 5.9.4', 'nestd == 0.3.1', # conditional 'uvloop == 0.17.0; sys_platform == "darwin"', diff --git a/requirements.txt b/requirements.txt index de412c5a2..69ab33175 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,5 @@ maturin==0.14.12 uvloop; platform_system!="Windows" watchdog==2.2.1 multiprocess==0.70.14 -psutil==5.9.4 jinja2==3.1.2 nestd==0.3.1 diff --git a/robyn/__init__.py b/robyn/__init__.py index 736f8a963..0728033f4 100644 --- a/robyn/__init__.py +++ b/robyn/__init__.py @@ -33,7 +33,7 @@ def __init__(self, file_object: str, config: Config = Config()) -> None: # If we are in dev mode, we need to setup the reloader # This process will be used by the watchdog observer while running the actual server as children processes - if self.config.dev and not os.environ.get("IS_RELOADER_SETUP", False): + if self.config.dev and not os.environ.get("IS_RELOADER_RUNNING", False): setup_reloader(self.directory_path, self.file_path) exit(0) diff --git a/robyn/reloader.py b/robyn/reloader.py index afb2ce848..f53fcc86a 100644 --- a/robyn/reloader.py +++ b/robyn/reloader.py @@ -3,7 +3,6 @@ import subprocess import sys import time -import psutil from watchdog.events import FileSystemEventHandler from watchdog.observers import Observer @@ -45,23 +44,23 @@ def terminating_signal_handler(_sig, _frame): class EventHandler(FileSystemEventHandler): def __init__(self, file_path: str) -> None: self.file_path = file_path + self.process = None # Keep track of the subprocess - self.last_reload = time.time() + self.last_reload = time.time() # Keep track of the last reload. EventHandler is initialized with the process. def stop_server(self): - for process in psutil.Process().children(recursive=True): - process.kill() - process.wait() # Required to avoid zombies + if self.process: + os.kill(self.process.pid, signal.SIGTERM) # Stop the subprocess using os.kill() def reload(self): self.stop_server() new_env = os.environ.copy() new_env[ - "IS_RELOADER_SETUP" + "IS_RELOADER_RUNNING" ] = "True" # This is used to check if a reloader is already running - subprocess.Popen( + self.process = subprocess.Popen( [sys.executable, *sys.argv], env=new_env, start_new_session=False, @@ -82,3 +81,4 @@ def on_modified(self, event) -> None: time.sleep(0.2) # Wait for the file to be fully written self.reload() +