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

JSON backend can be egregiously slow on network filesystems #235

Open
klauer opened this issue Mar 4, 2022 · 0 comments
Open

JSON backend can be egregiously slow on network filesystems #235

klauer opened this issue Mar 4, 2022 · 0 comments

Comments

@klauer
Copy link
Contributor

klauer commented Mar 4, 2022

This pattern was carried forward from the original implementation, just generalized: (I, uh, git blame shows me, but don't blame me 😬 )

Load/yield/save:

@contextlib.contextmanager
def _load_and_store_context(backend):
"""Context manager used to load, and optionally store the JSON database."""
db = backend._load_or_initialize()
yield db
backend.store(db)

Load on every method:

json = self._load_or_initialize()

This originally was likely an attempt to get around the inability to lock files on the filesystem / concurrent access / etc - all of those things a real database is meant to help with.

What would be a reasonable alternative here - at least keeping the spirit of the original, not just saving on exit?

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

1 participant