Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files are opened but not closed #674

Open
padraic-shafer opened this issue Mar 4, 2024 · 3 comments
Open

Files are opened but not closed #674

padraic-shafer opened this issue Mar 4, 2024 · 3 comments

Comments

@padraic-shafer
Copy link
Contributor

As an example, when a TiffAdapter is created it holds a handle to an open TIFF file (via tifffile.TiffFile). After __init__() completes, that file handle is used by calls to metadata(), read(), and read_block(). The latter two already cache the array data for future reads. I believe the file handle never gets closed until the server shuts down. I see this as hundreds of ResourceWarnings when running the test suite.

I expect other file-backed adapters act similarly.

With cached read operations already in use (and assuming metadata() results could be cached), is it necessary to keep the file open for performance (server response time)? Did earlier versions already try opening the file on demand when the cache misses?

Alternatively, I suppose the server could have a cold timeout...so that if a file hasn't been accessed for X minutes, then the file handle gets closed.

@padraic-shafer
Copy link
Contributor Author

Some of the ResourceWarnings can be addressed by improving our resource handling in the tests. PR #678 has been submitted to correct those.

@danielballan
Copy link
Member

I wonder whether object_cache should be overhauled ~now. Like the old (now replaced) implementation of tiled.client.cache.Cache, it's a proof of principle put in place when we were still evaluating whether Tiled was even viable as a concept.

I think something much, much simpler would address the use case. Perhaps a TTL cache of file handles.

@padraic-shafer
Copy link
Contributor Author

I think something much, much simpler would address the use case. Perhaps a TTL cache of file handles.

That makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants