diff --git a/tests/test_cli.py b/tests/test_cli.py index eb950ff88..0d34d1d36 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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: diff --git a/uvicorn/main.py b/uvicorn/main.py index 16f5aa117..3c59fa131 100644 --- a/uvicorn/main.py +++ b/uvicorn/main.py @@ -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: