Skip to content

PYTHON 5212 - Use asyncio.loop.sock_connect in _async_create_connection #2383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 13, 2025
Prev Previous commit
Next Next commit
Cleanup
  • Loading branch information
NoahStapp committed Jun 13, 2025
commit e08da843f4193cd86a49f911f27373ec9b8e3cbc
12 changes: 5 additions & 7 deletions test/asynchronous/test_async_loop_unblocked.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ async def test_client_does_not_block_loop(self):

# If the loop is being blocked, at least one iteration will have a latency much more than 0.1 seconds
async def background_task():
last_run = None
start = time.monotonic()
try:
while True:
if last_run is not None:
latencies.append(time.monotonic() - last_run)
last_run = time.monotonic()
start = time.monotonic()
await asyncio.sleep(0.1)
latencies.append(time.monotonic() - start)
except asyncio.CancelledError:
if last_run is not None:
latencies.append(time.monotonic() - last_run)
latencies.append(time.monotonic() - start)
raise

t = asyncio.create_task(background_task())
Expand All @@ -54,5 +52,5 @@ async def background_task():
self.assertLessEqual(
sorted(latencies, reverse=True)[0],
0.2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry only adding 100ms will be flaky, can we make this 1 full second?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I was slightly too optimistic about the EG host performance.

"Task took longer than twice its sleep time to run again",
"Background task was blocked from running",
)
Loading