Skip to content

Commit

Permalink
pythongh-111246: Don't log on redundant socket cleanup (python#111246)
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Oct 30, 2023
1 parent 21ff6be commit 21e9d8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/asyncio/unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ def _stop_serving(self, sock):
if path is not None:
try:
os.unlink(path)
except FileNotFoundError:
pass
except OSError as err:
logger.error('Unable to clean up listening UNIX socket '
'%r: %r', path, err)
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_asyncio/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ async def serve(*args):
srv.close()
self.assertFalse(os.path.exists(addr))

@socket_helper.skip_unless_bind_unix_socket
async def test_unix_server_cleanup_gone(self):
with test_utils.unix_socket_path() as addr:
async def serve(*args):
pass

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(addr)

srv = await asyncio.start_unix_server(serve, sock=sock)

os.unlink(addr)

srv.close()


@unittest.skipUnless(hasattr(asyncio, 'ProactorEventLoop'), 'Windows only')
class ProactorStartServerTests(BaseStartServer, unittest.TestCase):
Expand Down

0 comments on commit 21e9d8c

Please sign in to comment.