Skip to content

use _load_dotenv_from_env on reload for granian#5798

Merged
adhami3310 merged 1 commit into
mainfrom
use-_load_dotenv_from_env-on-reload-for-granian
Sep 18, 2025
Merged

use _load_dotenv_from_env on reload for granian#5798
adhami3310 merged 1 commit into
mainfrom
use-_load_dotenv_from_env-on-reload-for-granian

Conversation

@adhami3310

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to ensure the import change and callback registration work correctly

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@codspeed-hq

codspeed-hq Bot commented Sep 18, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5798 will not alter performance

Comparing use-_load_dotenv_from_env-on-reload-for-granian (79ca870) with main (6d8b083)

Summary

✅ 8 untouched

@adhami3310 adhami3310 merged commit 8661f7e into main Sep 18, 2025
41 checks passed
@adhami3310 adhami3310 deleted the use-_load_dotenv_from_env-on-reload-for-granian branch September 18, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants