Skip to content

Commit

Permalink
Fix: autoreload, restrict eventhandler from restart on open (flet-dev…
Browse files Browse the repository at this point in the history
…#3098)

Limit the restart of the running flet app to modify, created, deleted or moved file events
  • Loading branch information
auphof authored and 50Bytes-dev committed May 18, 2024
1 parent a818ad2 commit c0481af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sdk/python/packages/flet/src/flet/cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def on_any_event(self, event):
):
return

if self.watch_directory or event.src_path == self.script_path:
if (
self.watch_directory or event.src_path == self.script_path
) and event.event_type in ["modified", "deleted", "created", "moved"]:

current_time = time.time()
if (current_time - self.last_time) > 0.5 and self.is_running:
self.last_time = current_time
Expand Down

0 comments on commit c0481af

Please sign in to comment.