Repository navigation
Stop reloading a local plugin on its own Python bytecode writes - #15093
Conversation
The local plugin watcher reloads a plugin on every write under its directory. A plugin whose Python helper imports modules from that directory makes CPython write __pycache__/*.pyc, each write reloads the plugin, the reload restarts the helper, and the helper's next lazy import writes the next .pyc. The 150ms debounce coalesces a burst but cannot break that cycle, since each write comes from the helper the previous reload started. Ignore paths under __pycache__ (which covers the temp name CPython writes before renaming) and stray .pyc/.pyo files. Hidden files inside a plugin are still watched: entry points may live there, and the manual promises a reload for any saved file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
[Medium impact] The PR appears safe to merge; no blocking issue was found. SummaryStops Python cache writes inside local plugins from triggering reloads.
Reviews (2) · Last reviewed commit: "Ignore only __pycache__ below a plugin, ..." · Reviewed by Greptile |
…code Matching .pyc/.pyo and __pycache__ against the whole plugin-relative path also matched plugin directories themselves: moving in a plugin whose id is acme.pyc (a valid id) was ignored, as was every change to a plugin dir named __pycache__. Python 3 writes bytecode only into __pycache__, so the suffix check was never needed for the reload loop; drop it and require __pycache__ to sit inside a plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Reviewed and verified at 61c27da, against Fix pushed. Codex Medium's review found that the first commit matched Reproduced on a worker built from the Omarchy ISO, with the shell running from each tree: inside a local plugin, three Tests on the worker: Second opinion: Codex Medium, two rounds. The first round found the defect above. The second, on 61c27da, found nothing open. Independence is not guaranteed, because the reviewer can read this session's work. No competing pull requests were found. Still out of scope, as the description says: #12158 (a plugin writing its own Waiting on the maintainer. |
…om#15093) * Stop reloading a local plugin on its own Python bytecode writes The local plugin watcher reloads a plugin on every write under its directory. A plugin whose Python helper imports modules from that directory makes CPython write __pycache__/*.pyc, each write reloads the plugin, the reload restarts the helper, and the helper's next lazy import writes the next .pyc. The 150ms debounce coalesces a burst but cannot break that cycle, since each write comes from the helper the previous reload started. Ignore paths under __pycache__ (which covers the temp name CPython writes before renaming) and stray .pyc/.pyo files. Hidden files inside a plugin are still watched: entry points may live there, and the manual promises a reload for any saved file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com> * Ignore only __pycache__ below a plugin, not names that look like bytecode Matching .pyc/.pyo and __pycache__ against the whole plugin-relative path also matched plugin directories themselves: moving in a plugin whose id is acme.pyc (a valid id) was ignored, as was every change to a plugin dir named __pycache__. Python 3 writes bytecode only into __pycache__, so the suffix check was never needed for the reload loop; drop it and require __pycache__ to sit inside a plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com> --------- Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Codex Medium <noreply@openai.com> (cherry picked from commit c726e6a)
The shell's local plugin watcher reloads a plugin on every write under
~/.config/omarchy/plugins/<id>/, and that includes the bytecode a plugin's own Python helper writes. When the helper imports a module from inside the plugin directory, CPython writes__pycache__/<module>.cpython-314.pyc. The watcher sees it and reloads every plugin. The reload restarts the helper, and the helper's next lazy import writes the next.pyc. Reported withb.everythingfreezing the shell and withthefreshoffice.speaker-calibratorkilling its helper mid-measurement.The 150ms
localPluginReloadTimerinshell.qmlcoalesces a burst of events, but it cannot break this cycle. Each write comes from the helper that the previous reload started.localPluginIdForPath()now ignores any path with a__pycache__component, which also covers the temporary name CPython writes before it renames the file into place. It also ignores stray.pyc/.pyofiles. Everything else still reloads as before: a helper's.pysource, and hidden files inside a plugin, since entry points may live there and the manual promises a reload for any saved file.This does not cover #12158, where a plugin writes its own
data.jsonbeside its QML. Telling plugin state apart from plugin code means deciding what hot reload watches, for example an allow-list of QML, JS and manifests. That would also stop reloads for helper source and assets, so it is left to the maintainer.test/shell.d/fixtures/plugin-registry/shell.qmlasserts the new boundaries. On a worker built from the Omarchy ISO, its six bytecode assertions fail onquattroand pass with this change. In a shell launched from each tree, three realpython3 -c "import …"runs inside a local plugin caused 9 reloads onquattroand none with this change, while editing the helper's.pystill caused one. Codex Medium reviewed the mechanism and the change. It found that an earlier, broader version (ignoring hidden files at any depth) would have stopped hot reload for hidden entry points, and it asked for the extra path cases. Both are in this change, and its last round had nothing open.Fixes #11929