-
-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Except AttributeError
on sys.stdin.fileno()
for Windows IIS10
#1947
Conversation
[Montag 15:19] Fassel Andreas (BSH GDS-BCL3) If you start uvicorn in the context of Windows IIS10 no stdin exists, but exception is not OSError, but AttributeError with uvicorn-0.21.1.dist-info
I think we received a PR with this fix some time ago but it wasn't merged. We need to find out why... 🤔 |
Can I see the logs at least? I can't find anywhere about this issue. Do you have any reference? |
add log, web.config and patch, thanks for your support. |
Can you share it on the PR so I don't need to download anything? |
python.log_9732_20234248231.log
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Script">
<add name="PythonHandler"
path="*"
verb="*"
modules="httpPlatformHandler"
resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\IIS\DxxxCxP\xxxcheck\virtualpy3_11\Scripts\python.exe"
arguments="-m uvicorn app:app --reload --log-level trace --port %HTTP_PLATFORM_PORT%"
startupTimeLimit="20"
startupRetryCount="2"
stdoutLogEnabled="true"
stdoutLogFile="D:\IIS\DxxxCxP\xxxcheck\logs\python.log"
processesPerApplication="4">
<environmentVariables>
<environmentVariable name="SERVER_PORT"
value="%HTTP_PLATFORM_PORT%"/>
<environmentVariable name="PATH"
value="D:\IIS\DxxxCxP\xxxcheck\virtualpy3_11\Scripts;%PATH%"/>
<environmentVariable name="VIRTUAL_ENV"
value="D:\IIS\DxxxCxP\xxxcheck\virtualpy3_11"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration> """
Some light wrappers around Python's multiprocessing, to deal with cleanly
starting child processes.
"""
import multiprocessing
import os
import sys
from multiprocessing.context import SpawnProcess
from socket import socket
from typing import Callable, List, Optional
from uvicorn.config import Config
multiprocessing.allow_connection_pickling()
spawn = multiprocessing.get_context("spawn")
def get_subprocess(
config: Config,
target: Callable[..., None],
sockets: List[socket],
) -> SpawnProcess:
"""
Called in the parent process, to instantiate a new child process instance.
The child is not yet started at this point.
* config - The Uvicorn configuration instance.
* target - A callable that accepts a list of sockets. In practice this will
be the `Server.run()` method.
* sockets - A list of sockets to pass to the server. Sockets are bound once
by the parent process, and then passed to the child processes.
"""
# We pass across the stdin fileno, and reopen it in the child process.
# This is required for some debugging environments.
#stdin_fileno: Optional[int]
try:
stdin_fileno = sys.stdin.fileno()
except (AttributeError, OSError):
stdin_fileno = None
kwargs = {
"config": config,
"target": target,
"sockets": sockets,
"stdin_fileno": stdin_fileno,
}
return spawn.Process(target=subprocess_started, kwargs=kwargs)
def subprocess_started(
config: Config,
target: Callable[..., None],
sockets: List[socket],
stdin_fileno: Optional[int],
) -> None:
"""
Called when the child process starts.
* config - The Uvicorn configuration instance.
* target - A callable that accepts a list of sockets. In practice this will
be the `Server.run()` method.
* sockets - A list of sockets to pass to the server. Sockets are bound once
by the parent process, and then passed to the child processes.
* stdin_fileno - The file number of sys.stdin, so that it can be reattached
to the child process.
"""
# Re-open stdin.
if stdin_fileno is not None:
sys.stdin = os.fdopen(stdin_fileno)
# Logging needs to be setup again for each child.
config.configure_logging()
# Now we can call into `Server.run(sockets=sockets)`
target(sockets=sockets) |
I need you to paste the information on the PR. I'll not download any file. |
Now I understand... see above |
do you need support on this topic? What can i do to help you? |
|
AttributeError
on sys.stdin.fileno()
for Windows IIS10
👍 |
If you start uvicorn in the context of Windows IIS10 no stdin exists, but exception is not OSError, but AttributeError with uvicorn-0.21.1.dist-info
Summary
Checklist