-
Notifications
You must be signed in to change notification settings - Fork 501
Closed
Description
For example, running django web server normally sends continuous output to stdout/stderr; however, via python-dotenv it doesn't show the server output. This may have something to do with the fact that python-dotenv is using subprocess.Popen and then p.communicate() (which collects all the output when the process returns).
Here's a quick reproducing script, and output:
import logging
import sys
import time
logging.basicConfig() # set default stderr handler
log = logging.getLogger()
stdout_handler = logging.StreamHandler(sys.stdout)
log.addHandler(stdout_handler)
print('Starting running with handlers', log.handlers)
while True:
log.error('Test log')
time.sleep(1)and the output:
$ python test.py
Starting running with handlers [<StreamHandler <stderr> (NOTSET)>, <StreamHandler <stdout> (NOTSET)>]
ERROR:root:Test log
Test log
ERROR:root:Test log
Test log
^CTraceback (most recent call last):
File "test.py", line 13, in <module>
time.sleep(1)
KeyboardInterrupt
$ dotenv run python test.py
^C
Aborted!As a reference / possible solution, we can look at python-dotenv-run code which uses either ctx.exit(subprocess.call([command] + list(args), shell=True)) on windows or os.execlp(command, command, *args) otherwise.
p.s: I'll be happy to submit a PR if one of the solutions above is acceptable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels