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

Fix crash on exist with "--uds" if socket not exists #1725

Merged
merged 2 commits into from Oct 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/test_cli.py
Expand Up @@ -95,7 +95,6 @@ def test_cli_call_multiprocess_run() -> None:
def test_cli_uds(tmp_path: Path) -> None: # pragma: py-win32
runner = CliRunner()
uds_file = tmp_path / "uvicorn.sock"
uds_file.touch(exist_ok=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

This change has reduced coverage on this file. Added back in #1741

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Which line was reduced?

Copy link
Contributor

@iudeen iudeen Oct 28, 2022

Choose a reason for hiding this comment

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

Line 571 in main.py

due to this os.path.exists(config.uds)

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Let's test both scenarios - I'm already on it.


with mock.patch.object(Config, "bind_socket") as mock_bind_socket:
with mock.patch.object(Multiprocess, "run") as mock_run:
Expand Down
2 changes: 1 addition & 1 deletion uvicorn/main.py
Expand Up @@ -567,7 +567,7 @@ def run(
Multiprocess(config, target=server.run, sockets=[sock]).run()
else:
server.run()
if config.uds:
if config.uds and os.path.exists(config.uds):
os.remove(config.uds) # pragma: py-win32

if not server.started and not config.should_reload and config.workers == 1:
Expand Down