From eec75d80ad0dfbe19c01b788cb17bfbc3f69fcdd Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Thu, 22 Aug 2024 23:02:22 -0400 Subject: [PATCH] [fs-irods_18] during data object auto close, take care of iRODSFS handles first. --- irods/session.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/irods/session.py b/irods/session.py index 6bee2c31..723d635c 100644 --- a/irods/session.py +++ b/irods/session.py @@ -32,8 +32,15 @@ _sessions = None _sessions_lock = threading.Lock() - def _cleanup_remaining_sessions(): + try: + import fs_irods.iRODSFS, sys + lfs = list(sys.modules[fs_irods.iRODSFS.__module__].fses) + for fs in lfs: + fs._finalize_files() + except Exception as e: + logging.getLogger(__name__).debug('%r attempting to close iRODSFS file descriptors',e) + for fd in list(_fds.keys()): if not fd.closed: fd.close()