Skip to content

Commit e08da84

Browse files
committed
Cleanup
1 parent 92fae2c commit e08da84

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/asynchronous/test_async_loop_unblocked.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@ async def test_client_does_not_block_loop(self):
3030

3131
# If the loop is being blocked, at least one iteration will have a latency much more than 0.1 seconds
3232
async def background_task():
33-
last_run = None
33+
start = time.monotonic()
3434
try:
3535
while True:
36-
if last_run is not None:
37-
latencies.append(time.monotonic() - last_run)
38-
last_run = time.monotonic()
36+
start = time.monotonic()
3937
await asyncio.sleep(0.1)
38+
latencies.append(time.monotonic() - start)
4039
except asyncio.CancelledError:
41-
if last_run is not None:
42-
latencies.append(time.monotonic() - last_run)
40+
latencies.append(time.monotonic() - start)
4341
raise
4442

4543
t = asyncio.create_task(background_task())
@@ -54,5 +52,5 @@ async def background_task():
5452
self.assertLessEqual(
5553
sorted(latencies, reverse=True)[0],
5654
0.2,
57-
"Task took longer than twice its sleep time to run again",
55+
"Background task was blocked from running",
5856
)

0 commit comments

Comments
 (0)