From e371f39f15301e0c7eec8b17dd152f0dfde8b881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 28 Oct 2025 21:31:08 +0545 Subject: [PATCH] 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 --- sshfs/spec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sshfs/spec.py b/sshfs/spec.py index 046a6ec..88f7f2b 100644 --- a/sshfs/spec.py +++ b/sshfs/spec.py @@ -100,7 +100,8 @@ async def _connect( connect = sync_wrapper(_connect) - async def _finalize(self, pool, stack): + @staticmethod + async def _finalize(pool, stack): await pool.close() # If an error occurs while the SSHFile is trying to