Skip to content

Accept any awaitable in WaitIterator - #3771

Open
Cherith1222 wants to merge 1 commit into
tornadoweb:masterfrom
Cherith1222:fix/3001-waititerator-awaitables
Open

Cherith1222 wants to merge 1 commit into
tornadoweb:masterfrom
Cherith1222:fix/3001-waititerator-awaitables

Conversation

@Cherith1222

@Cherith1222 Cherith1222 commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

gen.WaitIterator is documented to accept any awaitable, but the constructor passed each argument straight to future_add_done_callback. A native coroutine then failed with AttributeError. Each argument is now converted with convert_yielded. A Future is returned unchanged, so current_future and duplicate-future handling stay the same.

Fixes #3001.

No changelog entry. Tornado adds those under a released version heading, and there is no unreleased section.

Test Plan

On Windows, Python 3.13:

  • python -m tornado.test.runtests tornado.test.gen_test.WaitIteratorTest → before the change, the new test errored with AttributeError; after, 7 OK.
  • python -m tornado.test.runtests tornado.test.gen_test → 83 OK.
  • flake8 7.3.0 and black 26.5.1 --check passed on tornado/gen.py and tornado/test/gen_test.py.

Not run: mypy, tox -e lint,docs,py3, the rest of the suite, and non-Windows platforms.

AI assistance

Drafted with Cursor. The account owner authorized opening this pull request. Cherith reviewed this diff and confirmed it with the person who helped draft it. There is no Co-authored-by, Reviewed-by, or Signed-off-by trailer.

WaitIterator is documented to take awaitables, but its constructor passed each argument straight to future_add_done_callback, so a native coroutine failed with AttributeError. Convert each argument with convert_yielded. Futures are returned unchanged, so current_future and duplicate-future handling stay the same.

Fixes tornadoweb#3001.

AI-assisted (Cursor); not yet reviewed by a human.

This branch has not been deployed

No deployments
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.

WaitIterator constructor typing is not match with documentation

1 participant