Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,11 @@ def test_custom_loop__not_importable_custom_loop_setup_function(caplog: pytest.L
'Error loading custom loop setup function. Attribute "non_existing_setup_function" not found in module "tests.test_config".' # noqa: E501
== error_messages.pop(0)
)


def test_setup_event_loop_is_removed(caplog: pytest.LogCaptureFixture) -> None:
config = Config(app=asgi_app)
with pytest.raises(
AttributeError, match="The `setup_event_loop` method was replaced by `get_loop_factory` in uvicorn 0.36.0."
):
config.setup_event_loop()
9 changes: 8 additions & 1 deletion uvicorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,16 @@ def load(self) -> None:

self.loaded = True

def setup_event_loop(self) -> None:
raise AttributeError(
"The `setup_event_loop` method was replaced by `get_loop_factory` in uvicorn 0.36.0.\n"
"None of those methods are supposed to be used directly. If you are doing it, please let me know here: "
"https://github.com/Kludex/uvicorn/discussions/2706. Thank you, and sorry for the inconvenience."
)

def get_loop_factory(self) -> Callable[[], asyncio.AbstractEventLoop] | None:
if self.loop in LOOP_FACTORIES:
loop_factory: Callable | None = import_from_string(LOOP_FACTORIES[self.loop])
loop_factory: Callable[..., Any] | None = import_from_string(LOOP_FACTORIES[self.loop])
else:
try:
return import_from_string(self.loop)
Expand Down
Loading