Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable hot reload on windows #290

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions robyn/dev_event_handler.py
Original file line number Diff line number Diff line change
@@ -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))