Skip to content

Commit

Permalink
Fix crash on exist with "--uds" if socket not exists (#1725)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
JGoutin and Kludex committed Oct 27, 2022
1 parent b06cc63 commit 5ba3f13
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
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)

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

0 comments on commit 5ba3f13

Please sign in to comment.