Repository: fsspec/filesystem_spec

Issue:
Archive filesystems do not close file after deletion.
We noticed this undesired behaviour in one of out processes using fsspec:

```python
import fsspec
import psutil
import gc
fs = fsspec.filesystem("tar", fo="./foo.tar")

# here other things happen, eg
# filelist = fs.find("/")

del fs
gc.collect()  # returns 0, so fs is not collectable...

print(psutil.Process().open_files())
```
prints out
`[popenfile(path='/path/to/foo.tar', fd=4, position=4096, mode='r', flags=557056)]`

This has been observed on at least zip and tar filesystems, and lead to filling up our harddrives very quicky on our servers...

Comments:

Patch:
diff --git a/fsspec/implementations/http.py b/fsspec/implementations/http.py
index 0802932..126b410 100644
--- a/fsspec/implementations/http.py
+++ b/fsspec/implementations/http.py
@@ -209,7 +209,6 @@ class HTTPFileSystem(AsyncFileSystem):
         kw.update(kwargs)
         logger.debug(url)
 
-        # TODO: extract into testable utility function?
         if start is not None or end is not None:
             if start == end:
                 return b""
diff --git a/fsspec/implementations/libarchive.py b/fsspec/implementations/libarchive.py
index 8e99bea..28845c3 100644
--- a/fsspec/implementations/libarchive.py
+++ b/fsspec/implementations/libarchive.py
@@ -91,6 +91,7 @@ class LibArchiveFileSystem(AbstractArchiveFileSystem):
 
     root_marker = ""
     protocol = "libarchive"
+    cachable = False
 
     def __init__(
         self,
diff --git a/fsspec/implementations/reference.py b/fsspec/implementations/reference.py
index 9de586c..85b1e1d 100644
--- a/fsspec/implementations/reference.py
+++ b/fsspec/implementations/reference.py
@@ -197,15 +197,7 @@ class ReferenceFileSystem(AsyncFileSystem):
     def _cat_common(self, path):
         path = self._strip_protocol(path)
         logger.debug(f"cat: {path}")
-        # TODO: can extract and cache templating here
-        if self.dataframe:
-            part = self.df.loc[path]
-            if part["data"]:
-                part = part["data"]
-            else:
-                part = part[["url", "offset", "size"]]
-        else:
-            part = self.references[path]
+        part = self.references[path]
         if isinstance(part, str):
             part = part.encode()
         if isinstance(part, bytes):
diff --git a/fsspec/implementations/tar.py b/fsspec/implementations/tar.py
index dfea48c..6ac7f0e 100644
--- a/fsspec/implementations/tar.py
+++ b/fsspec/implementations/tar.py
@@ -23,6 +23,7 @@ class TarFileSystem(AbstractArchiveFileSystem):
 
     root_marker = ""
     protocol = "tar"
+    cachable = False
 
     def __init__(
         self,
diff --git a/fsspec/implementations/zip.py b/fsspec/implementations/zip.py
index 5452bf7..2ede0dc 100644
--- a/fsspec/implementations/zip.py
+++ b/fsspec/implementations/zip.py
@@ -17,6 +17,7 @@ class ZipFileSystem(AbstractArchiveFileSystem):
 
     root_marker = ""
     protocol = "zip"
+    cachable = False
 
     def __init__(
         self,


Test patch:
diff --git a/fsspec/implementations/tests/test_zip.py b/fsspec/implementations/tests/test_zip.py
index 2d9c26b..0aab4a2 100644
--- a/fsspec/implementations/tests/test_zip.py
+++ b/fsspec/implementations/tests/test_zip.py
@@ -32,3 +32,10 @@ def test_fsspec_get_mapper():
         assert isinstance(mapping, fsspec.mapping.FSMap)
         items = dict(mapping.getitems(keys))
         assert items == {"a": b"", "b": b"hello", "deeply/nested/path": b"stuff"}
+
+
+def test_not_cached():
+    with tempzip(archive_data) as z:
+        fs = fsspec.filesystem("zip", fo=z)
+        fs2 = fsspec.filesystem("zip", fo=z)
+        assert fs is not fs2