MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / _get_timeout

Method _get_timeout

nonebot/drivers/httpx.py:114–132  ·  view source on GitHub ↗
(self, timeout: TimeoutTypes | UnsetType)

Source from the content-addressed store, hash-verified

112 return self._client
113
114 def _get_timeout(self, timeout: TimeoutTypes | UnsetType) -> httpx.Timeout:
115 _timeout = None
116 if isinstance(timeout, Timeout):
117 avg_timeout = timeout.total and timeout.total / 4
118 timeout_kwargs: dict[str, float | None] = exclude_unset(
119 {
120 "timeout": avg_timeout,
121 "connect": timeout.connect,
122 "read": timeout.read,
123 }
124 )
125 if timeout_kwargs:
126 _timeout = httpx.Timeout(**timeout_kwargs)
127 elif timeout is not UNSET:
128 _timeout = httpx.Timeout(timeout)
129
130 if _timeout is None:
131 return self._timeout
132 return _timeout
133
134 @override
135 async def request(self, setup: Request) -> Response:

Callers 2

requestMethod · 0.95
stream_requestMethod · 0.95

Calls 1

exclude_unsetFunction · 0.90

Tested by

no test coverage detected