MCPcopy
hub / github.com/encode/httpx / request_context

Function request_context

httpx/_exceptions.py:367–379  ·  view source on GitHub ↗

A context manager that can be used to attach the given request context to any `RequestError` exceptions that are raised within the block.

(
    request: Request | None = None,
)

Source from the content-addressed store, hash-verified

365
366@contextlib.contextmanager
367def request_context(
368 request: Request | None = None,
369) -> typing.Iterator[None]:
370 """
371 A context manager that can be used to attach the given request context
372 to any `RequestError` exceptions that are raised within the block.
373 """
374 try:
375 yield
376 except RequestError as exc:
377 if request is not None:
378 exc.request = request
379 raise exc

Callers 12

iter_bytesMethod · 0.85
iter_textMethod · 0.85
iter_linesMethod · 0.85
iter_rawMethod · 0.85
closeMethod · 0.85
aiter_bytesMethod · 0.85
aiter_textMethod · 0.85
aiter_linesMethod · 0.85
aiter_rawMethod · 0.85
acloseMethod · 0.85
_send_single_requestMethod · 0.85
_send_single_requestMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected