Skip to content

bpo-36802: Drop awrite()/aclose(), support await write() and await close() instead - #13099

Merged
asvetlov merged 10 commits into
python:masterfrom
asvetlov:drop-awrite
May 9, 2019
Merged

bpo-36802: Drop awrite()/aclose(), support await write() and await close() instead#13099
asvetlov merged 10 commits into
python:masterfrom
asvetlov:drop-awrite

Conversation

@asvetlov

@asvetlovasvetlov commented May 5, 2019

Copy link
Copy Markdown
Contributor

writelines() supports await syntax as well

https://bugs.python.org/issue36802

@asvetlov
asvetlov requested a review from gpshead as a code ownerMay 5, 2019 19:04
@asvetlov

Copy link
Copy Markdown
ContributorAuthor

The PR requires #13098
That's why I've merged that code to this branch.
I'm trying to keep PRs isolated but it is not always possible, sorry.

@gpshead
gpshead removed their request for review May 5, 2019 20:30
Comment threadDoc/library/asyncio-stream.rst Outdated
Comment threadDoc/library/asyncio-stream.rst Outdated
return fut
if not self._protocol._paused:
return self._complete_fut
return self._loop.create_task(self.drain())

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.

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

Copy link
Copy Markdown
ContributorAuthor

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 no writer._paused attribute but writer._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.

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.

Ah, I see, never mind. Could you please add a comment before return self._complete_fut that it's a "fast path"?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done

@asvetlov

Copy link
Copy Markdown
ContributorAuthor

Is the PR good now?

1st1
1st1 approved these changes May 9, 2019
@asvetlov
asvetlov merged commit a076e4f into python:masterMay 9, 2019
@bedevere-bot

Copy link
Copy Markdown

@asvetlov: Please replace # with GH- in the commit message next time. Thanks!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@asvetlov@bedevere-bot@1st1@the-knights-who-say-ni