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

Cut BaseProtocol circular reference on close. #1049

Merged
merged 4 commits into from
Oct 9, 2023
Merged

Cut BaseProtocol circular reference on close. #1049

merged 4 commits into from
Oct 9, 2023

Commits on Oct 9, 2023

  1. Cut BaseProtocol circular reference on close.

    A bound method contains a reference to the instance it's bound to.
    Most of the time, bound methods are created lazily at access time by
    the descriptor protocol and discarded after calling. But saving a bound
    method as another attribute on the instance creates a long-lived cycle,
    here `.timeout_callback.__self__`, that needs to be explicitly broken
    if we don't want to wake up python's garbage collector to do it.
    
    Without this change, the new assertion in the tests would fail, and
    `pytest --pdb` would show the bound methods `_on_timeout` and
    `_on_waiter_completed` at the end of `p gc.get_referrers(protoref())`.
    pteromys authored and elprans committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    d148b75 View commit details
    Browse the repository at this point in the history
  2. Just remove the callbacks instead.

    pteromys authored and elprans committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    6a02962 View commit details
    Browse the repository at this point in the history
  3. Fix line length for flake8.

    pteromys authored and elprans committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    b8e6833 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ddb4505 View commit details
    Browse the repository at this point in the history