File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,7 +220,13 @@ def _on_timeout():
220220 # timeout. We do NOT fail fast merely on a falsy open_new return
221221 # value: that is unreliable across platforms (it can be falsy
222222 # even when a browser did open) and would break working
223- # interactive logins. See issue #458. Placed before the generic
223+ # interactive logins. Note this fast-fail only covers the case
224+ # where webbrowser.get() raises; the more common headless case
225+ # (no browser registered, so open_new() returns False without
226+ # raising) is NOT caught here and instead falls through to the
227+ # bounded redirect-callback timeout below, which is the real
228+ # safeguard against blocking forever. See issue #458. Placed
229+ # before the generic
224230 # ``except Exception`` so this RuntimeError propagates instead of
225231 # being swallowed and retried against the remaining ports.
226232 msg = (
Original file line number Diff line number Diff line change @@ -237,7 +237,10 @@ def test_get_tokens_does_not_hang_when_no_callback_received(
237237 client_id = "mock-id" ,
238238 idp_endpoint = InHouseOAuthEndpointCollection (),
239239 http_client = MagicMock (),
240- redirect_callback_timeout_seconds = 2 ,
240+ # Sub-second so this real-wallclock wait stays negligible in the
241+ # fast/mocked unit suite. The wait IS the timeout, so there is no
242+ # setup racing against it that a shorter bound could make flaky.
243+ redirect_callback_timeout_seconds = 0.5 ,
241244 )
242245
243246 # No callback is ever delivered to the redirect server. Run the flow in
@@ -325,7 +328,10 @@ def run_flow(port):
325328 client_id = "mock-id" ,
326329 idp_endpoint = InHouseOAuthEndpointCollection (),
327330 http_client = MagicMock (),
328- redirect_callback_timeout_seconds = 2 ,
331+ # Sub-second: bounds the stalled request-line read. Keeps the
332+ # per-attempt wait negligible so even the rare TOCTOU retry loop
333+ # stays fast in the mocked unit suite.
334+ redirect_callback_timeout_seconds = 0.5 ,
329335 )
330336
331337 result = {}
You can’t perform that action at this time.
0 commit comments