quart
quart copied to clipboard
Hypercorn Does Not Load Environment Variables From Session
Issue Description When running Hypercorn directly from the command line, it does not properly access environment variables set in the current shell session. This causes applications to default to fallback values instead of using the configured environment variables.
Steps to Reproduce
- Set environment variables in shell:
export REDIS_HOST="my-redis-server" export REDIS_PORT="6379" - Run application with Hypercorn:
hypercorn main:app - Observe application logs showing default values instead of environment variables:
********************************************* REDIS_HOST: localhost REDIS_PORT: 6380 REDIS_PASS: None REDIS_USE_SSL: False REDIS_POOL_SIZE: 10 *********************************************
Expected Behavior Hypercorn should load and make available all environment variables from the parent shell session, allowing the application to access them via os.environ or os.getenv().
Actual Behavior Environment variables set in the shell session are not accessible to the application when started with Hypercorn directly.
Workarounds
- Set environment variables inline with the Hypercorn command:
- Use python-dotenv in your application to load variables from a .env file
- In Docker deployments, explicitly pass environment variables through the container
Environment:
- Python version: 3.11
- Quart version: 0.20.0
- Hypercorn: 0.17.3