Skip to content

Commit

Permalink
improve flaky asyncio test (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky authored Jun 10, 2021
1 parent bdc99ae commit 8eaf3ac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/test_server_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,17 @@ def connection_made(self, transport):

protocol.transport.close() # close isn't synchronous and there's no notification that it's done
# so we have to wait a bit
yield from asyncio.sleep(0.1)
self.assertTrue(len(server.active_connections) == 0)
allowed_delay = 1
deadline = time.monotonic() + allowed_delay
while time.monotonic() <= deadline:
yield from asyncio.sleep(0.1)
if len(server.active_connections) == 0:
break
else:
self.assertTrue(
len(server.active_connections) == 0,
msg="connections not closed within {} seconds".format(allowed_delay),
)

server.server_close()

Expand Down

0 comments on commit 8eaf3ac

Please sign in to comment.