Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fa07b35
Implement loop.sendfile()
asvetlov Jan 22, 2018
8ebd388
Fix notes
asvetlov Jan 22, 2018
c7194f7
Add NEWS
asvetlov Jan 22, 2018
1632e0a
Fix error text
asvetlov Jan 22, 2018
535be77
Raise an exception on sendfile via closing transport
asvetlov Jan 22, 2018
bd8c515
Add more tests
asvetlov Jan 23, 2018
fab4669
More tests
asvetlov Jan 23, 2018
2f51d6a
Update comment
asvetlov Jan 23, 2018
d36fcdf
More tests
asvetlov Jan 23, 2018
defc61c
Merge branch 'master' into sendfile
asvetlov Jan 23, 2018
2ae8bf5
Stop file reading early
asvetlov Jan 23, 2018
6b30924
Revert back, test was failed
asvetlov Jan 23, 2018
9271eb1
Merge branch 'master' into sendfile
asvetlov Jan 24, 2018
d2bb432
Clarify empty_waiter possible values
asvetlov Jan 24, 2018
2bf14d3
Add docs
asvetlov Jan 24, 2018
c1ad2f4
Add a test
asvetlov Jan 24, 2018
57f02cf
Merge branch 'master' into sendfile
asvetlov Jan 24, 2018
968c8c5
Inline variable
asvetlov Jan 24, 2018
b905d1d
Fix error texts
asvetlov Jan 24, 2018
2969cf4
Merge branch 'master' into sendfile
asvetlov Jan 24, 2018
a9af6c7
Merge branch 'master' into sendfile
asvetlov Jan 26, 2018
e5f24b6
_SenfileProtocol -> _SendfileFallbackProtocol
asvetlov Jan 26, 2018
bc458b3
Raise an exception for bad transport type
asvetlov Jan 26, 2018
e1a173e
Drop assert
asvetlov Jan 26, 2018
032bd40
Tune exception text
asvetlov Jan 26, 2018
b466ed3
Cancel sendfile waiter on transport closing
asvetlov Jan 26, 2018
359181d
Extract drain() method
asvetlov Jan 26, 2018
1169407
Fix sendfile tests
asvetlov Jan 27, 2018
312e2c5
Update docstring
asvetlov Jan 27, 2018
cdc898d
Simplify code
asvetlov Jan 27, 2018
df556f2
Mark proactor socket transport as sendfile-fallback
asvetlov Jan 27, 2018
5a9d056
Cleanup more resources in tests
asvetlov Jan 27, 2018
7f99184
Cleanup more resources in tests
asvetlov Jan 27, 2018
b8f2c1a
Fix a bug in reading from not ready future
asvetlov Jan 27, 2018
4224bde
Fix proactor support
asvetlov Jan 27, 2018
3975b5a
Skip windows specific tests on Unix
asvetlov Jan 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert back, test was failed
  • Loading branch information
asvetlov committed Jan 23, 2018
commit 6b30924f2c44eaac726150e8c7cbf5099f99a303
6 changes: 3 additions & 3 deletions Lib/asyncio/base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,13 @@ async def _sendfile_fallback(self, transp, file, offset, count):
blocksize = min(count - total_sent, blocksize)
if blocksize <= 0:
return total_sent
fut = proto._paused
if fut is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be more readable if _SendfileProtocol exposed a drain coro-method:

await proto.drain()
...
transp.write(..)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where _SendfileProtocol's drain would look like:

async def drain():
    if self._can_write is None:
        return
    await self._can_write
    self._can_write = None

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No.
The _paused attribute should be removed on writer resuming.
Doing it on draining is awkward and error prone.

Also I don't line drain name, it was always confusing.
We do access to attributes of other classes already in asyncio often enough.
A new private method for just replacing plain attribute access? Do we really need it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A new private method for just replacing plain attribute access? Do we really need it?

Yes, because the code is super hard to read right now. drain isn't really confusing in this context.

Since it's a private method and the code will certainly look nicer/tighter, then why not?

await fut
view = memoryview(buf)[:blocksize]
read = file.readinto(view)
if not read:
return total_sent # EOF
fut = proto._paused
if fut is not None:
await fut
transp.write(view)
total_sent += read
finally:
Expand Down