Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21e9d8c

Browse files
committed
gh-111246: Don't log on redundant socket cleanup (#111246)
1 parent 21ff6be commit 21e9d8c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Lib/asyncio/unix_events.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ def _stop_serving(self, sock):
477477
if path is not None:
478478
try:
479479
os.unlink(path)
480+
except FileNotFoundError:
481+
pass
480482
except OSError as err:
481483
logger.error('Unable to clean up listening UNIX socket '
482484
'%r: %r', path, err)

Lib/test/test_asyncio/test_server.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,21 @@ async def serve(*args):
175175
srv.close()
176176
self.assertFalse(os.path.exists(addr))
177177

178+
@socket_helper.skip_unless_bind_unix_socket
179+
async def test_unix_server_cleanup_gone(self):
180+
with test_utils.unix_socket_path() as addr:
181+
async def serve(*args):
182+
pass
183+
184+
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
185+
sock.bind(addr)
186+
187+
srv = await asyncio.start_unix_server(serve, sock=sock)
188+
189+
os.unlink(addr)
190+
191+
srv.close()
192+
178193

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

0 commit comments

Comments
 (0)