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

Undo write if it fails. #15

Closed
wants to merge 2 commits into from
Closed

Undo write if it fails. #15

wants to merge 2 commits into from

Conversation

ArturGaspar
Copy link

Fixes #14.

The flush() is necessary because of the following scenario:

  • write exceeds fs capacity but isn't flushed, write call doesn't fail, file is at position beyond fs capacity;
  • next call writes enough to flush;
  • next call fails but going back to previous position still exceeds fs capacity;

It could however become a performance issue. Could be fixed by a file object that keeps a buffer in memory by itself and only calls write in KB-sized blocks.

@codecov-io
Copy link

Current coverage is 96.68%

Merging #15 into master will decrease coverage by -1.84% as of 5e10838

Powered by Codecov. Updated on successful CI builds.

ssize = struct.pack(self.SIZE_FORMAT, len(string))
self.f.write(ssize)
self.f.flush()
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should catch only IOError here?

@eliasdorneles
Copy link
Member

@ArturGaspar do you think you could come up with a test for this?
I suppose the tricky bit would be to simulate the limited filesystem. Perhaps there are other ways of making a write call fail at some point?

@ArturGaspar
Copy link
Author

@eliasdorneles A proper test would need a mock file that mimics the buffer mechanism and has a size limit. I'll try.

@eliasdorneles
Copy link
Member

@dangra would love to hear your feelings about this one. :)

@dangra
Copy link
Member

dangra commented Mar 9, 2016

+1 I ❤️ it but I can have 🍶 only after a test case.

@dangra
Copy link
Member

dangra commented Mar 9, 2016

Btw, queuelib is really to close 100% test coverage, would love anyone volunteer to get there.

@dangra
Copy link
Member

dangra commented Mar 16, 2016

@shaneaevans commented (trough other channel) that flushing on every call can hurt performance. I think we need some benchmarks to compare.

@Gallaecio
Copy link
Member

Would it make sense to make flushing optional?

@Gallaecio
Copy link
Member

Or should we just close this for now?

@Gallaecio Gallaecio closed this Oct 18, 2019
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

Successfully merging this pull request may close these issues.

Failed write corrupts LIFO queue file
5 participants