Skip to content

fix: read the tornado global live instead of an import-time snapshot - #696

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/jd/fix/wait-regressions/read-tornado-global-live-instead-import-time--6f0fbb9c
Aug 6, 2026
Merged

fix: read the tornado global live instead of an import-time snapshot#696
mergify[bot] merged 1 commit into
mainfrom
devs/jd/fix/wait-regressions/read-tornado-global-live-instead-import-time--6f0fbb9c

Conversation

@jd

@jd jd commented Aug 6, 2026

Copy link
Copy Markdown
Owner

#679 replaced if tornado: with a _HAS_TORNADO bool computed once at
import, to stop truthy-bool flagging the module object as always true.
But only one of the two call sites was converted: the retry() decorator
still dereferences the live tornado global right after testing the
snapshot. The two desync as soon as anything reassigns the global.

A/B verified against a2af454: tenacity.tornado = None followed by any
@tenacity.retry decoration returned normally before, and now raises
AttributeError: 'NoneType' object has no attribute 'gen'. Nulling the
module global is the standard way a downstream suite exercises the
non-tornado path without uninstalling tornado.

Replace the constant with a _has_tornado() function so both call sites
read the live global and cannot drift apart. As a bonus this needs no
redundant-expr suppression: the check reads as a plain return rather than
the left operand of an and.

#679 replaced `if tornado:` with a `_HAS_TORNADO` bool computed once at
import, to stop `truthy-bool` flagging the module object as always true.
But only one of the two call sites was converted: the `retry()` decorator
still dereferences the live `tornado` global right after testing the
snapshot. The two desync as soon as anything reassigns the global.

A/B verified against a2af454: `tenacity.tornado = None` followed by any
`@tenacity.retry` decoration returned normally before, and now raises
`AttributeError: 'NoneType' object has no attribute 'gen'`. Nulling the
module global is the standard way a downstream suite exercises the
non-tornado path without uninstalling tornado.

Replace the constant with a `_has_tornado()` function so both call sites
read the live global and cannot drift apart. As a bonus this needs no
`redundant-expr` suppression: the check reads as a plain return rather than
the left operand of an `and`.

Change-Id: I6f0fbb9cad3d4e46599b0cae1b5b60378742fd1f
@jd
jd marked this pull request as ready for review August 6, 2026 06:50
@mergify

mergify Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-06 06:50 UTC · Rule: default · triggered by rule autoqueue
  • Checks skipped · PR is already up-to-date
  • Merged2026-08-06 06:51 UTC · at 920076096f697e3542312b7c7896e9a6892480d7 · squash

This pull request spent 9 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Aug 6, 2026
@mergify
mergify Bot merged commit 949dcfa into main Aug 6, 2026
9 checks passed
@mergify
mergify Bot deleted the devs/jd/fix/wait-regressions/read-tornado-global-live-instead-import-time--6f0fbb9c branch August 6, 2026 06:51
@mergify mergify Bot removed the queued label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant