Skip to content

Conversation

@shrxya07
Copy link

@shrxya07 shrxya07 commented Nov 26, 2025

Summary

This PR fixes RecursionError reported in issue #4532.

Fix

A _instrumented guard flag was added to urllib3 instrumentation to ensure
that _instrument() cannot run multiple times. The absence of this guard
caused recursive instrumentation and eventually RecursionError.

Details

The change:

  • Adds _instrumented = False at the class level
  • Early-returns from _instrument() if instrumentation already happened

Result

This prevents infinite recursion and ensures stable instrumentation behavior.

Fixes: #4532

Added a guard (_instrumented flag) to prevent urllib3 instrumentation from running multiple times, which caused RecursionError (#4532). This ensures _instrument() exits early if already applied.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 26, 2025

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: shrxya07 / name: shrxya07 (031f0b1)

@xrmx
Copy link
Contributor

xrmx commented Nov 26, 2025

@shrxya07 thanks for the PR, how do you reproduce it? Is it manual calling the instrumentor more than one time or in a different way? Please add a test, an entry in changelog and setup pre-commit so CI will be happy

@xrmx xrmx moved this to Reviewed PRs that need fixes in @xrmx's Python PR digest Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

RecursionError: maximum recursion depth exceeded

3 participants