docs: clarify wrap_file ownership and lifecycle#3423
docs: clarify wrap_file ownership and lifecycle#3423nightcityblade wants to merge 2 commits intopython-trio:mainfrom
Conversation
Clarify in the wrap_file docstring that closing the async wrapper closes the underlying file, that GC does not auto-close, and that the original sync file should not be used concurrently. Closes python-trio#3379 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3423 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19424 19436 +12
Branches 1318 1318
===============================================
+ Hits 19424 19436 +12
🚀 New features to boost your workflow:
|
A5rocks
left a comment
There was a problem hiding this comment.
- please make CI pass
- if we don't have tests for this behavior, writing this out in the docs means we promise it... so please add tests!
| file objects. If you need synchronous access, use the | ||
| :attr:`~AsyncIOWrapper.wrapped` attribute. |
There was a problem hiding this comment.
This doesn't make sense, that's literally the file handle in question?
| Returns: | ||
| An :term:`asynchronous file object` that wraps ``file`` | ||
|
|
||
| The returned wrapper object shares the underlying file with the original |
There was a problem hiding this comment.
I think maybe this should be indented into the returns section? Not sure about how that would look formatting-wise.
|
Thanks, that makes sense. Rather than land wording that over-promises behavior without coverage, I opened a separate docs-only clarification for the related |
|
I'm not sure how your comment is related to this PR. What does Anyways, it seems you have been opening too many PRs recently... 68 in the last 2 weeks! Unfortunately I think the open issues on Trio need a bunch of thought to how to solve them, so I'm going to close this. Feel free to reopen it whenever you've slowed down how many PRs you make! |
Fixes #3379
Document what happens to the wrapped sync file when the async wrapper is closed, whether garbage collection closes it automatically, and why the original sync file should not be used concurrently while wrapped.