Skip to content

Commit e371f39

Browse files
committed
sshfs: make _finalize method static to allow garbage collection
Using a bound method with weakref.finalize was keeping a reference to the `SSHFileSystem` instance, preventing it from being garbage collected. See note at the end of the Python documentation for [`weakref.finalize`][1]: > Note: It is important to ensure that func, args and kwargs do not own any references to obj, > either directly or indirectly, since otherwise obj will never be garbage collected. > In particular, func should not be a bound method of obj. [1]: https://docs.python.org/3/library/weakref.html#weakref.finalize
1 parent 5c32631 commit e371f39

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sshfs/spec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ async def _connect(
100100

101101
connect = sync_wrapper(_connect)
102102

103-
async def _finalize(self, pool, stack):
103+
@staticmethod
104+
async def _finalize(pool, stack):
104105
await pool.close()
105106

106107
# If an error occurs while the SSHFile is trying to

0 commit comments

Comments
 (0)