DefaultFormatter fails to initialize correctly when a frozen application is run as a service on Windows #2248
Unanswered
johan-ronnkvist
asked this question in
Potential Issue
Replies: 2 comments 1 reply
-
|
I encounter this problem too , when I use the pythonservice.exe running it. how do you resolve it? |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
I just hit this bug too, just running a server with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
I'm starting a uvicorn server as a service on Windows, through
win32serviceutil.ServiceFramework. The application has been packaged/frozen with PyInstaller.When starting the application as a service, it crashes with the following stack information
Additional information:
This discussion suggests that the issue comes from
sys.stdoutandsys.stderrbeing set to None in this context.I have verified that these are
Nonefor this context, in my own code that executed prior to the above mentioned stack trace.Resolution:
From inspecting the initialization of logging, with the context and information above - I realized that I could bypass the usage of
sys.stdout.isatty()andsys.stderr.isatty()by providing the argumentuse_colorswhen callinguvicorn.run(). This has shown to resolve my crash on startup.Suggested change:
I would suggest that no access to
sys.stderrorsys.stdoutis allowed before verifying that it's notNoneRelated discussions:
ValueError: Unable to configure formatter 'default'. Similar error message, but likely a different root cause.
Beta Was this translation helpful? Give feedback.
All reactions