Skip to content
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

Use a2wsgi.WSGIMiddleware replace WSGIMiddleware #1303

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -25,8 +25,6 @@ files =
uvicorn/protocols/websockets/auto.py,
uvicorn/supervisors/__init__.py,
uvicorn/middleware/debug.py,
uvicorn/middleware/wsgi.py,
tests/middleware/test_wsgi.py,
uvicorn/supervisors/watchgodreload.py,
uvicorn/logging.py,
uvicorn/middleware/asgi2.py,
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -62,6 +62,7 @@ def get_packages(package):
"watchgod>=0.6",
"python-dotenv>=0.13",
"PyYAML>=5.1",
"a2wsgi>=1.4.0,<2.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

My only question here is: should this go in extra_requirements so that people have it when installing via pip install uvicorn[standard] or directly in the minimal_requirements section ?

the idea of uvicorn[standard] vs uvicorn was in summary cpython vs pure-python, or high-speed vs minimal, so I'd thought we better put it in minimal_requirements instead but I'm open on anything really

Copy link
Member Author

Choose a reason for hiding this comment

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

If we think Uvicorn can be used as a WSGI Server, then it should be added to minimal_requirements.

But in README:

Uvicorn is an ASGI web server implementation for Python.

So I'm not so sure...

What are @tomchristie 's thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should add it in the docs and then close #177

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree.

]


Expand Down
125 changes: 0 additions & 125 deletions tests/middleware/test_wsgi.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_config.py
Expand Up @@ -15,6 +15,7 @@

import pytest
import yaml
from a2wsgi import WSGIMiddleware
from asgiref.typing import ASGIApplication, ASGIReceiveCallable, ASGISendCallable, Scope
from pytest_mock import MockerFixture

Expand All @@ -23,7 +24,6 @@
from uvicorn.config import LOGGING_CONFIG, Config
from uvicorn.middleware.debug import DebugMiddleware
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
from uvicorn.middleware.wsgi import WSGIMiddleware
from uvicorn.protocols.http.h11_impl import H11Protocol


Expand Down
11 changes: 10 additions & 1 deletion uvicorn/config.py
Expand Up @@ -28,12 +28,21 @@
# enable this functionality.
pass

try:
Copy link
Member

Choose a reason for hiding this comment

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

depending on the answer to the comment above @abersheeran the try / catch may not be necessary

from a2wsgi import WSGIMiddleware
except ImportError:
from uvicorn._types import WSGIApp

class WSGIMiddleware: # type: ignore
def __init__(self, app: WSGIApp, workers: int = 10):
raise RuntimeError("Please install `a2wsgi` for serving WSGI applications")


from uvicorn.importer import ImportFromStringError, import_from_string
from uvicorn.middleware.asgi2 import ASGI2Middleware
from uvicorn.middleware.debug import DebugMiddleware
from uvicorn.middleware.message_logger import MessageLoggerMiddleware
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
from uvicorn.middleware.wsgi import WSGIMiddleware

HTTPProtocolType = Literal["auto", "h11", "httptools"]
WSProtocolType = Literal["auto", "none", "websockets", "wsproto"]
Expand Down
179 changes: 0 additions & 179 deletions uvicorn/middleware/wsgi.py

This file was deleted.