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
bpo-44899: add support for archiving changing files with tarfile #30426
base: main
Are you sure you want to change the base?
bpo-44899: add support for archiving changing files with tarfile #30426
Conversation
This PR is stale because it has been open for 30 days with no activity. |
bump |
Look ok to me.
Ran 491 tests in 10.948s
OK (skipped=8)
== Tests result: SUCCESS ==
1 test OK.
Total duration: 11.2 sec
Tests result: SUCCESS
cpython on bpo-44899/tarfile-changing-files [$] via
raise exception("unexpected end of data") | ||
if exception is not None: | ||
raise exception("unexpected end of data") | ||
print("warning: file changed as we read it") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there are 5 blocks to copy, and the file size changes during the read of block 2, how many times are we going to get the warning printed?
# If there's data to follow, append it. | ||
if fileobj is not None: | ||
copyfileobj(fileobj, self.fileobj, tarinfo.size, bufsize=bufsize) | ||
copybuf = io.BytesIO() | ||
tarinfo.size = copyfileobj(fileobj, copybuf, tarinfo.size, exception=None, bufsize=self.copybufsize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original bpo issue was for a system that had limited resources, but this solution is going to store the entire, possibly large, file in memory.
raise exception("unexpected end of data") | ||
if exception is not None: | ||
raise exception("unexpected end of data") | ||
print("warning: file changed as we read it") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use print()
, use warnings.warn
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I will use warnings.warn instead of print().
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
https://bugs.python.org/issue44899