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

Comments

2 participants
@parkerduckworth
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

This comment has been minimized.

Owner

msiemens commented Apr 17, 2018

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

@parkerduckworth

This comment has been minimized.

Contributor

parkerduckworth commented Apr 23, 2018

Cool. Will create one now.

@msiemens

This comment has been minimized.

Owner

msiemens commented Apr 24, 2018

Closed in #212, which also is released now 🙃

@msiemens msiemens closed this Apr 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment