Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VirDomainWrapper: avoid keeping libvirt object ref in locals
Complementary to the previous commit, avoid keeping keeping libvirt object (function) reference in locals, which become closure for the wrapper. Do getattr (again) when the actual call is made. The primary reason for this change is to avoid leaking objects during tests, but also this fixes a rare failure more - if external caller would cache returned function, it wouldn't work after reconnection. For example: # libvirt_domain is VirDomainWrapper() object >>> func = libvirt_domain.pause >>> func() >>> func() If reconnection happens during the first call (or between calls), the second call would use stale function reference.
- Loading branch information