Skip to content

Commit 1b64c9e

Browse files
fix: robyn dev loading bug (#743)
* fix: robyn dev loading bug * fix bug * fix types * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent afe1745 commit 1b64c9e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

robyn/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def start_dev_server(config: Config, file_path: Optional[str] = None):
7979
if file_path is None:
8080
return
8181

82-
directory_path = Path.cwd()
83-
absolute_file_path = (directory_path / file_path).resolve()
82+
absolute_file_path = (Path.cwd() / file_path).resolve()
83+
directory_path = absolute_file_path.parent
8484

8585
if config.dev and not os.environ.get("IS_RELOADER_RUNNING", False):
8686
setup_reloader(str(directory_path), str(absolute_file_path))

robyn/reloader.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import subprocess
55
import sys
66
import time
7+
from typing import List
78

89
from watchdog.events import FileSystemEventHandler
910
from watchdog.observers import Observer
@@ -29,7 +30,7 @@ def compile_rust_files(directory_path: str):
2930
else:
3031
print("Compiled rust file : %s", rust_file)
3132

32-
return True
33+
return rust_files
3334

3435

3536
def create_rust_file(file_name: str):
@@ -51,12 +52,9 @@ def create_rust_file(file_name: str):
5152
print("Created rust file : %s", rust_file)
5253

5354

54-
def clean_rust_build(directory_path: str, file_path: str):
55-
rust_binaries = glob.glob(os.path.join(directory_path, "**/*.so"), recursive=True)
56-
55+
def clean_rust_binaries(rust_binaries: List[str]):
5756
for file in rust_binaries:
5857
print("Cleaning rust file : %s", file)
59-
6058
os.remove(file)
6159

6260

@@ -97,6 +95,7 @@ def __init__(self, file_path: str, directory_path: str) -> None:
9795
self.file_path = file_path
9896
self.directory_path = directory_path
9997
self.process = None # Keep track of the subprocess
98+
self.built_rust_binaries = [] # Keep track of the built rust binaries
10099

101100
self.last_reload = time.time() # Keep track of the last reload. EventHandler is initialized with the process.
102101

@@ -113,8 +112,8 @@ def reload(self):
113112
print(f"Reloading {self.file_path}...")
114113
arguments = [arg for arg in sys.argv[1:] if not arg.startswith("--dev")]
115114

116-
clean_rust_build(self.directory_path, self.file_path)
117-
compile_rust_files(self.directory_path)
115+
clean_rust_binaries(self.built_rust_binaries)
116+
self.built_rust_binaries = compile_rust_files(self.directory_path)
118117

119118
self.process = subprocess.Popen(
120119
[sys.executable, *arguments],

0 commit comments

Comments
 (0)