Fokko commented on code in PR #4070:
URL: https://github.com/apache/iceberg-python/pull/4070#discussion_r4786381106
##########
tests/io/test_pyarrow.py:
##########
@@ -4539,6 +4543,42 @@ def test_pyarrow_file_io_fs_by_scheme_cache() -> None:
assert pyarrow_file_io.fs_by_scheme.cache_info().hits == 2 # type:
ignore
+@contextmanager
+def _cycle_collector_disabled() -> Iterator[None]:
+ was_enabled = gc.isenabled()
+ gc.disable()
+ try:
+ yield
+ finally:
+ if was_enabled:
+ gc.enable()
+
+
+def test_pyarrow_file_io_freed_by_refcounting() -> None:
+ with _cycle_collector_disabled():
+ file_io = PyArrowFileIO()
+ file_io.fs_by_scheme("file", None)
+ file_io_ref = weakref.ref(file_io)
+ del file_io
+
+ assert file_io_ref() is None
+
+
+def test_pyarrow_file_io_pickle_round_trip_keeps_cache_and_refcounting() ->
None:
+ file_io = PyArrowFileIO()
+ file_io.fs_by_scheme("file", None)
+
+ restored = pickle.loads(pickle.dumps(file_io))
+ assert isinstance(restored.fs_by_scheme("file", None), LocalFileSystem)
+ assert restored.fs_by_scheme.cache_info().currsize == 1 # type: ignore
Review Comment:
mypy on 3.11 reports this ignore as unused, which is what fails the
`lint-and-unit-test (3.11)` job right now:
```suggestion
assert restored.fs_by_scheme.cache_info().currsize == 1
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]