fix: read the tornado global live instead of an import-time snapshot - #696
Merged
mergify[bot] merged 1 commit intoAug 6, 2026
Conversation
#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
marked this pull request as ready for review
August 6, 2026 06:50
Contributor
Merge Queue Status
This pull request spent 9 seconds in the queue, including 1 second running CI. Required conditions to merge
|
mergify
Bot
deleted the
devs/jd/fix/wait-regressions/read-tornado-global-live-instead-import-time--6f0fbb9c
branch
August 6, 2026 06:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#679 replaced
if tornado:with a_HAS_TORNADObool computed once atimport, to stop
truthy-boolflagging the module object as always true.But only one of the two call sites was converted: the
retry()decoratorstill dereferences the live
tornadoglobal right after testing thesnapshot. The two desync as soon as anything reassigns the global.
A/B verified against a2af454:
tenacity.tornado = Nonefollowed by any@tenacity.retrydecoration returned normally before, and now raisesAttributeError: 'NoneType' object has no attribute 'gen'. Nulling themodule 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 sitesread the live global and cannot drift apart. As a bonus this needs no
redundant-exprsuppression: the check reads as a plain return rather thanthe left operand of an
and.