Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python: fix circular reference in auto-bounded wrapper methods
When the user of Python objects inheriting from `Wrapper` attempt to access an unkonwn method (i.e., a method that is not manually written and included in the bindings)will automatically search the cffi auto-generated bindings for functions with a matching name. Once a match is found, the function is bound as a method to the object to effectively cache the search and make future accesses quicker. This bound method creates a circular reference between the `Wrapper` and it's method. In the case of `Future`s, this resulted in a leak and the piling up of open futures, as documented in flux-framework#2566. To avoid this circular reference, use the `weakref` library to create a weak reference to the object when constructing the bound method. When the object leaves scope, it is now immediately destructed. Remove the no longer necessary calls to `future._clear()` Closes flux-framework#2566.
- Loading branch information