From 2e4b8b9a71f398751e887771f55af3e497681862 Mon Sep 17 00:00:00 2001 From: guilefoylegaurav Date: Fri, 7 Oct 2022 21:33:37 +0530 Subject: [PATCH] fix: enable hot reload on windows (#283) * fix(dev_event_handler.py): use platform specific python3 alias to spawn processes --- robyn/dev_event_handler.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/robyn/dev_event_handler.py b/robyn/dev_event_handler.py index c22dd541c..96028a8bd 100644 --- a/robyn/dev_event_handler.py +++ b/robyn/dev_event_handler.py @@ -1,4 +1,5 @@ import subprocess +import sys from watchdog.events import FileSystemEventHandler @@ -7,11 +8,14 @@ class EventHandler(FileSystemEventHandler): def __init__(self, file_name) -> None: self.file_name = file_name self.processes = [] + self.python_alias = "python3" if not sys.platform.startswith("win32") else "python" + self.shell = True if sys.platform.startswith("win32") else False + def start_server_first_time(self) -> None: if self.processes: raise Exception("Something wrong with the server") - self.processes.append(subprocess.Popen(["python3", self.file_name], start_new_session=False)) + self.processes.append(subprocess.Popen([self.python_alias, self.file_name], shell = self.shell, start_new_session=False)) def on_any_event(self, event) -> None: """ @@ -22,5 +26,5 @@ def on_any_event(self, event) -> None: if len(self.processes) > 0: for process in self.processes: - process.terminate() - self.processes.append(subprocess.Popen(["python3", self.file_name], start_new_session=False)) + process.terminate() + self.processes.append(subprocess.Popen([self.python_alias, self.file_name], shell = self.shell, start_new_session=False))