python / python/cpython

urllib.request.urlopen hangs for multiple minutes with timeout=30 and works with timeout=1

Open
#125,049 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:
import urllib.request
urllib.request.urlopen(urllib.request.Request("https://pypi.org/pypi/MozPhab/json"), timeout=30)

Somehow this hangs, and Control+C doesn't stop it. The same URL loads instantly on Firefox and Node.js. Any help to investigate this further will be appreciated. (Could be related to #95838, except I don't have any VPN on this machine.)

Coming from https://bugzilla.mozilla.org/show_bug.cgi?id=1919884.

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing the urllib.request.urlopen call with a Request for the pypi.org URL on Windows using Python 3.12, comparing timeout=30 with timeout=1. Read the related issue #95838 and investigate where the request stops responding; done means the long hang is explained and the reported behavior is fixed or clearly narrowed down.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.