Addressed Ruff checks for Unix socket startup path handling.

This commit is contained in:
2026-06-11 15:11:51 -04:00
parent 446c0cd9ca
commit 4c4f31b940
+6 -2
View File
@@ -202,8 +202,12 @@ class MetricsServer:
) )
else: else:
socket_path = Path(self._address.path) socket_path = Path(self._address.path)
# This runs once before binding the Unix site, so synchronous
# path checks are simpler than offloading startup setup.
try: try:
mode = socket_path.stat(follow_symlinks=False).st_mode mode = socket_path.stat( # noqa: ASYNC240
follow_symlinks=False,
).st_mode
except FileNotFoundError: except FileNotFoundError:
pass pass
else: else:
@@ -229,7 +233,7 @@ class MetricsServer:
raise OSError(errno.EADDRINUSE, msg) raise OSError(errno.EADDRINUSE, msg)
with contextlib.suppress(FileNotFoundError): with contextlib.suppress(FileNotFoundError):
socket_path.unlink() socket_path.unlink() # noqa: ASYNC240
site = web.UnixSite(self._runner, self._address.path) site = web.UnixSite(self._runner, self._address.path)
await site.start() await site.start()