-
-
Notifications
You must be signed in to change notification settings - Fork 22
Add support for async files as request body #217
Conversation
|
||
|
||
# XX this should return an async iterator | ||
def _request_bytes_iterable(request, state_machine): | ||
""" | ||
An iterable that serialises a set of bytes for the body. | ||
""" | ||
|
||
def all_pieces_iter(): |
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.
I'm not super happy with this function, there's probably a simpler way to do this rather than a direct translation.
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.
Possibly. Maybe @njsmith know how to improve this? In any case, this isn't blocking, so I'll merge this pull request.
69b3aab
to
1d379e9
Compare
1d379e9
to
7f6bd7e
Compare
Codecov Report
@@ Coverage Diff @@
## master #217 +/- ##
==========================================
- Coverage 99.15% 98.79% -0.37%
==========================================
Files 21 22 +1
Lines 3196 3234 +38
==========================================
+ Hits 3169 3195 +26
- Misses 27 39 +12
|
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.
Thanks!
|
||
|
||
# XX this should return an async iterator | ||
def _request_bytes_iterable(request, state_machine): | ||
""" | ||
An iterable that serialises a set of bytes for the body. | ||
""" | ||
|
||
def all_pieces_iter(): |
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.
Possibly. Maybe @njsmith know how to improve this? In any case, this isn't blocking, so I'll merge this pull request.
This PR adds support async files like
trio.wrap_file(open())
andanyio.aopen()
and does some refactoring that will allow us to accept other async iterables as data sources easily.set_file_position()
andrewind_body()
able to handle async filesunasync.py
file tohip.util
for small unasync-related utilities likeanext()
andawait_if_coro()
. See Provide common replacement utils / functions many projects will need unasync#65 for more info here too.read_timeout
toAnyIOSocket.receive_some()
, don't know how that bug wasn't caught earlier.body=
.test/with_dummyserver/async/
.test/with_dummyserver/async_only/
for test cases that shouldn't be unasync-ed, things specific to an async library