Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Blocking synchronous I/O (time.sleep, urllib) inside async event loop degrades performance

Open
#56 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python

Research direction

Start in local_browser.py at _is_local_cdp_available(), _local_cdp_page_targets(), _ensure_local_cdp_page_target(), and _ensure_local_cdp_browser(); inspect how these helpers are called and review the existing httpx dependency in pyproject.toml. Replace blocking HTTP and sleep operations with async equivalents, then verify CDP startup does not block or prevent cancellation of the polling loop.

Written by the indexing model from the issue text.

Description

Description

In \local_browser.py, several synchronous I/O operations run inside async methods, blocking the asyncio event loop:

  1. _is_local_cdp_available()\ (line 58) and _local_cdp_page_targets()\ (line 73) use \urllib.request\ synchronously
  2. _ensure_local_cdp_browser()\ (line 262) uses \ ime.sleep(0.2)\ in a polling loop, blocking the loop for up to 10 seconds
  3. _ensure_local_cdp_page_target()\ (line 93) uses synchronous urllib

\httpx\ is already listed as a dependency in \pyproject.toml\ (line 11) but isn't used anywhere.

Impact

  • The event loop is blocked during CDP browser startup for up to 10 seconds
  • \ ime.sleep()\ is not interruptible (unlike \syncio.sleep())
  • Concurrent operations on the same event loop cannot make progress
  • The polling loop cannot be cancelled mid-wait

Suggested Fix

Replace the synchronous helpers with async versions using \httpx.AsyncClient, convert _ensure_local_cdp_browser\ to async, and use \syncio.sleep()\ instead of \ ime.sleep().

The fix is straightforward since httpx is already a project dependency.

Dominant language
Python
Stars
6k
Forks
385
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/Webwright

All issues in microsoft/Webwright

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.