Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This won't meaningfully affect most users, so I won't feel bad if this is closed :-) It's often important for performance to control when garbage collection runs and to reduce the need to run garbage collection in the first place. During AbstractionConnection.on_connect, it's common to raise and catch ResponseError, since e.g. CLIENT SETINFO is very new. However, because response is in a local, it creates ref cycles that keep all locals in all calling stack frames alive. The use of a local to store the exception is unfortunate, since exceptions hold references to their tracebacks, which hold references to the relevant frames, which holds a reference to the local exception. See https://peps.python.org/pep-0344/#open-issue-garbage-collection and https://peps.python.org/pep-3110/#rationale This breaks the cycle by deleting the local when we raise, so frames are destroyed by the normal reference counting mechanism.
- Loading branch information