Skip to content

Commit

Permalink
"Fix" the failing asyncio tests by adding a sleep() call
Browse files Browse the repository at this point in the history
  • Loading branch information
1st1 committed Oct 8, 2023
1 parent 52ff91a commit df9576c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ async def start_server():
self.loop.call_soon(srv.close)
await srv.wait_closed()

if (
self.implementation == 'asyncio'
and sys.version_info[:3] >= (3, 12, 0)
):
# asyncio regression in 3.12 -- wait_closed()
# doesn't wait for `close()` to actually complete.
# https://github.com/python/cpython/issues/79033
await asyncio.sleep(1)

# Check that the server cleaned-up proxy-sockets
for srv_sock in srv_socks:
self.assertEqual(srv_sock.fileno(), -1)
Expand Down Expand Up @@ -168,6 +177,15 @@ async def start_server_sock():
srv.close()
await srv.wait_closed()

if (
self.implementation == 'asyncio'
and sys.version_info[:3] >= (3, 12, 0)
):
# asyncio regression in 3.12 -- wait_closed()
# doesn't wait for `close()` to actually complete.
# https://github.com/python/cpython/issues/79033
await asyncio.sleep(1)

# Check that the server cleaned-up proxy-sockets
for srv_sock in srv_socks:
self.assertEqual(srv_sock.fileno(), -1)
Expand Down Expand Up @@ -205,6 +223,15 @@ async def start_server_ephemeral_ports():
self.loop.call_soon(srv.close)
await srv.wait_closed()

if (
self.implementation == 'asyncio'
and sys.version_info[:3] >= (3, 12, 0)
):
# asyncio regression in 3.12 -- wait_closed()
# doesn't wait for `close()` to actually complete.
# https://github.com/python/cpython/issues/79033
await asyncio.sleep(1)

# Check that the server cleaned-up proxy-sockets
for srv_sock in srv_socks:
self.assertEqual(srv_sock.fileno(), -1)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ async def start_server():
self.loop.call_soon(srv.close)
await srv.wait_closed()

if (
self.implementation == 'asyncio'
and sys.version_info[:3] >= (3, 12, 0)
):
# asyncio regression in 3.12 -- wait_closed()
# doesn't wait for `close()` to actually complete.
# https://github.com/python/cpython/issues/79033
await asyncio.sleep(1)

# Check that the server cleaned-up proxy-sockets
for srv_sock in srv_socks:
self.assertEqual(srv_sock.fileno(), -1)
Expand Down Expand Up @@ -116,6 +125,15 @@ async def start_server_sock(start_server):
self.loop.call_soon(srv.close)
await srv.wait_closed()

if (
self.implementation == 'asyncio'
and sys.version_info[:3] >= (3, 12, 0)
):
# asyncio regression in 3.12 -- wait_closed()
# doesn't wait for `close()` to actually complete.
# https://github.com/python/cpython/issues/79033
await asyncio.sleep(1)

# Check that the server cleaned-up proxy-sockets
for srv_sock in srv_socks:
self.assertEqual(srv_sock.fileno(), -1)
Expand Down

0 comments on commit df9576c

Please sign in to comment.