Skip to content

Commit

Permalink
Release v0.26.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Apr 5, 2023
1 parent 97e2c0c commit 5dcfdf2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions integration_tests/base_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os


import pathlib

from robyn import WS, Robyn, Request, Response, jsonify, serve_file, serve_html
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"',
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions robyn/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import subprocess
import sys
import time
import psutil

from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
Expand Down Expand Up @@ -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,
Expand All @@ -82,3 +81,4 @@ def on_modified(self, event) -> None:

time.sleep(0.2) # Wait for the file to be fully written
self.reload()

0 comments on commit 5dcfdf2

Please sign in to comment.