Feature/clone function#86
Merged
Merged
Conversation
Alviner
approved these changes
Aug 19, 2023
dd52463 to
cda62fa
Compare
AIOFile.clone() bumps a ref-count so close() is deferred until all clones are released. FileIOCloner wraps this for the high-level async_open wrappers.
38cb295 to
0c2f547
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new asynchronous file cloning feature to the
aiofilelibrary, allowing multiple independent file-like objects to share a single file descriptor with separate offsets. This enables concurrent reading (and potentially writing) from the same file without reopening it, which can improve performance in certain scenarios. The change includes a newclonehelper, updates to the coreAIOFileclass, and corresponding tests and documentation.New file cloning feature:
clonehelper function andFileIOClonerclass toaiofile.utils, allowing users to create independent file-like clones from an existing file object. This enables concurrent operations with separate offsets on the same file descriptor.aiofile/__init__.pyto exportcloneandFileIOCloner. [1] [2] [3]Core class enhancements:
AIOFileclass to support reference counting for clones, ensuring the file is only closed when all clones are released. Added aclone()async method and internal locking for thread safety. [1] [2]Documentation:
README.mdexplaining theclonehelper, including a practical example and caveats for Windows users.Testing:
tests/test_aio.pyto verify the behavior of file cloning, including correct reading, offset handling, and reference-counted closing. [1] [2]