Skip to content

Commit

Permalink
fix: enable hot reload on windows (sparckles#283) (sparckles#290)
Browse files Browse the repository at this point in the history
* fix(dev_event_handler.py): use platform specific python3 alias to spawn processes
  • Loading branch information
guilefoylegaurav authored and Shending-Help committed Oct 19, 2022
1 parent 47137ac commit 6b146c2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions robyn/dev_event_handler.py
@@ -1,4 +1,5 @@
import subprocess
import sys

from watchdog.events import FileSystemEventHandler

Expand All @@ -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:
"""
Expand All @@ -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))

0 comments on commit 6b146c2

Please sign in to comment.