From 2423cc5e54b0133ffc8b5665255145a85d82e34e Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Mon, 14 Nov 2022 09:21:20 -0500 Subject: [PATCH 1/2] Try to work around lack of concurrency-safety in fsspec See --- datalad_fuse/fuse_.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/datalad_fuse/fuse_.py b/datalad_fuse/fuse_.py index 8c7a590..720a182 100644 --- a/datalad_fuse/fuse_.py +++ b/datalad_fuse/fuse_.py @@ -163,7 +163,10 @@ def getattr(self, path, fh=None): fsspec_file, timestamp=self._adapter.get_commit_datetime(path) ) if to_close: - fsspec_file.close() + try: + fsspec_file.close() + except KeyError: + pass else: # TODO: although seems to be logical -- seems to cause logging etc # lgr.error("ENOENTing %s %s", path, fh) @@ -259,7 +262,10 @@ def release(self, path, fh): # files, so we need to provide some proper use of lru_cache # to have not recently used closed if f is not None and not f.closed: - f.close() + try: + f.close() + except KeyError: + pass return 0 def readlink(self, path): From da59235c4cde1ea44020fb5cb510f158c0949307 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 15 Nov 2022 08:54:50 -0500 Subject: [PATCH 2/2] Log a DEBUG message on KeyError --- datalad_fuse/fuse_.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/datalad_fuse/fuse_.py b/datalad_fuse/fuse_.py index 720a182..42b4d07 100644 --- a/datalad_fuse/fuse_.py +++ b/datalad_fuse/fuse_.py @@ -165,8 +165,8 @@ def getattr(self, path, fh=None): if to_close: try: fsspec_file.close() - except KeyError: - pass + except KeyError as e: + lgr.debug("KeyError encountered while closing file: %s", e) else: # TODO: although seems to be logical -- seems to cause logging etc # lgr.error("ENOENTing %s %s", path, fh) @@ -264,8 +264,8 @@ def release(self, path, fh): if f is not None and not f.closed: try: f.close() - except KeyError: - pass + except KeyError as e: + lgr.debug("KeyError encountered while closing file: %s", e) return 0 def readlink(self, path):