Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
bpo-36802: Drop awrite()/aclose(), support await write() and await close() instead#13099
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The PR requires#13098 |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
return fut | ||
if not self._protocol._paused: | ||
return self._complete_fut | ||
return self._loop.create_task(self.drain()) |
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 idea is to avoid creating task in majority of the cases, e.g.:
In the stream__init__
:
self._nop=self.loop.create_future()self._nop.set_result(None)
and then in_fast_drain
:
ifnotself._paused:returnself._nop
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.
But I do almost the same a few lines above.
There is nowriter._paused
attribute butwriter._protocol._paused
one (which has undefined state if the protocol is closing).
That's why I have slightly more comlex logic that you mentioned in a comment but the functionality is the same.
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.
Ah, I see, never mind. Could you please add a comment beforereturn self._complete_fut
that it's a "fast path"?
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.
Done
Is the PR good now? |
bedevere-bot commentedMay 9, 2019
@asvetlov: Please replace |
Uh oh!
There was an error while loading.Please reload this page.
writelines()
supports await syntax as wellhttps://bugs.python.org/issue36802