Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ioloop,concurrent: Fix reference cycles #3315

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

bdarnell
Copy link
Member

Convert the circlerefs script into a regular unit test and expand it with new cases. Testing tornado.concurrent.run_on_executor as described in #2620 reveals several reference cycles in Future done callbacks.

Fixes #2620

This script was only ever run irregularly on its own; bring it in
to the test suite so it can be run automatically.
In a few places we were referring to a future via a closure instead
of using the reference passed as an argument to the callback.  This
sometimes causes a reference cycle that can slow GC. This commit
adds a test which covers two of the cases (chain_future and the
concurrent.future branch of add_future) while the third was found by
inspecting other calls to add_done_callback for obvious instances of
this pattern.

Fixes tornadoweb#2620
Local/attribute dicts are reported a bit differently here.
Pypy doesn't have the same refcount fast-path as cpython so the
gc behavior is different and this test is irrelevant.
@bdarnell bdarnell merged commit a192634 into tornadoweb:master Aug 22, 2023
11 checks passed
@bdarnell bdarnell deleted the circlerefs branch August 22, 2023 23:49
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.

Memory issue: Possible reference cycle with run_on_executor
1 participant