use _load_dotenv_from_env on reload for granian#5798
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR improves the hot reload functionality for Granian backend servers by changing how environment variables are loaded during development. The change modifies the exec.py file to use a callback-based approach instead of loading .env files only at server startup.
Specifically, the code switches from passing env_files=_paths_from_environment() or None to the Granian server constructor to using granian_app.on_reload(_load_dotenv_from_env). This registers a callback function that reloads environment variables whenever the application code changes during hot reloads.
This change enhances the developer experience by ensuring that modifications to .env files are automatically picked up during hot reloads without requiring a full server restart. The modification affects only the development mode Granian backend runner and aligns with Granian becoming the default backend server for Reflex, ensuring it has feature parity with other server implementations for environment variable handling.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it only affects development mode behavior
- Score reflects a focused change that improves developer experience without touching production code paths
- Pay close attention to
reflex/utils/exec.pyto ensure the import change and callback registration work correctly
1 file reviewed, no comments
CodSpeed Performance ReportMerging #5798 will not alter performanceComparing Summary
|
No description provided.