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

call os.fsync() following flush() #208

Closed
parkerduckworth opened this issue Apr 9, 2018 · 3 comments
Closed

call os.fsync() following flush() #208

parkerduckworth opened this issue Apr 9, 2018 · 3 comments

Comments

@parkerduckworth
Copy link
Contributor

parkerduckworth commented Apr 9, 2018

In tinydb/storages.py, line 112, a call to self._handle.flush() is made, in the write() method inside the class JSONStorage:

    def write(self, data):
        self._handle.seek(0)
        serialized = json.dumps(data, **self.kwargs)
        self._handle.write(serialized)
        self._handle.flush()
        self._handle.truncate()

Is the goal of this call to flush to ensure all internal buffers associated with self._handle are written to disk?

If so, it may be a good idea to make a call to os.fsync() to ensure this behavior.
ref: Python Docs

I have already implemented this change in my fork. If this is the case, I will create a PR.

@msiemens
Copy link
Owner

Yes, as far as I can remember, that's the intent. I'm always glad to accept PRs 🙂

@parkerduckworth
Copy link
Contributor Author

Cool. Will create one now.

@msiemens
Copy link
Owner

Closed in #212, which also is released now 🙃

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