Skip to content

Commit 8caa2ec

Browse files
authored
Add no-op close() and flush() methods to PackedObjectReader, CallbackStreamWrapper, and ZlibLikeBaseStreamDecompresser (#205)
When the packed object are returned they still should support close() and flush(), because in aiida-core TextIOWrapper is used as a context manager, its __exit__ calls close(), which propagates to the underlying stream. The methods are intentionally no-ops because these readers don't own the underlying file handles they read from.
1 parent e5cb644 commit 8caa2ec

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

disk_objectstore/utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,12 @@ def writable() -> bool:
548548
def closed(self) -> bool:
549549
return self._fhandle.closed
550550

551+
def close(self) -> None:
552+
"""Close the reader. Does not close the underlying file handle since it is shared."""
553+
554+
def flush(self) -> None:
555+
"""Flush is a no-op for a read-only stream."""
556+
551557
@staticmethod
552558
def seekable() -> bool:
553559
"""Return whether object supports random access."""
@@ -683,6 +689,12 @@ def writable() -> bool:
683689
def closed(self) -> bool:
684690
return self._stream.closed
685691

692+
def close(self) -> None:
693+
"""Close the wrapper. Does not close the underlying stream."""
694+
695+
def flush(self) -> None:
696+
"""Flush is a no-op for a read-only stream."""
697+
686698
def seekable(self) -> bool:
687699
"""Return whether object supports random access."""
688700
return self._stream.seekable()
@@ -834,6 +846,12 @@ def closed(self) -> bool:
834846
self._lazy_uncompressed_stream is None or self._lazy_uncompressed_stream.closed
835847
)
836848

849+
def close(self) -> None:
850+
"""Close the decompresser. Does not close the underlying compressed stream."""
851+
852+
def flush(self) -> None:
853+
"""Flush is a no-op for a read-only stream."""
854+
837855
def read(self, size: int = -1) -> bytes:
838856
"""
839857
Read and return up to n bytes.

0 commit comments

Comments
 (0)