A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: fix file deletion race in file watcher (#9344)
Akshay Agrawal94dd8156c1f1
diff --git a/marimo/_utils/file_watcher.py b/marimo/_utils/file_watcher.pyindex b8655a5ac3..a413a20c94 100644--- a/marimo/_utils/file_watcher.py+++ b/marimo/_utils/file_watcher.py@@ -108,13 +108,18 @@ class PollingFileWatcher(FileWatcher):# File exists again; reset the missing counterself._missing_count = 0- # Check for file changes+ # Check for file changes. Note: the file may be removed between+ # the exists() check above and the _get_modified() call here+ # (common on Windows, where deletion is asynchronous). In that+ # case _get_modified() returns None; skip this cycle so we don't+ # fire a spurious callback.modified = self._get_modified()- if self.last_modified is None:- self.last_modified = modified- elif modified != self.last_modified:- self.last_modified = modified- await self.on_file_changed()+ if modified is not None:+ if self.last_modified is None:+ self.last_modified = modified+ elif modified != self.last_modified:+ self.last_modified = modified+ await self.on_file_changed()await asyncio.sleep(self.POLL_SECONDS)