-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make pause/resume_reading idepotent and no-op for closed transports #528
Conversation
Lib/asyncio/proactor_events.py
Outdated
logger.debug("%r resumes reading", self) | ||
elif not self._paused: | ||
if self._loop.get_debug(): | ||
logger.debug("%r not paused", self) |
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'd change these debug messages to more descriptive ones:
%r not paused
->%r: ignoring resume_reading() call; already reading
%r already paused
->%r: ignoring pause_reading() call; already paused
# pause/resume reading is no-op on closed transport | ||
tr.pause_reading() | ||
self.assertFalse(tr._paused) | ||
tr._paused = True |
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 wonder if we need a public Transport.is_reading()
method.
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'd add Transport.paused
property instead
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.
We usually prefer methods to properties: see Transport.is_closing()
for instance. Anyways, do you use _paused
attribute anywhere in aiohttp? Maybe we should create a separate issue to discuss this.
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.
aiohttp maintains paused
state separately from asyncio transport. it would be useful to have public api for that.
in aiohttp paused
state is maintained by different edges, protocol pauses transport
when it get enough data, but resume happen from other edge, when user reads-out data from incoming stream. that is the reason why I think pause/resume should be ideponent and no-op during closing stage.
updated debug messages @1st1 do we still need to support _SelectorSslTransport (legacy)? |
|
that depends on availability of ssl's |
Isn't it always available in 3.5/3.6?
Yeah, I was planning to do a cleanup myself at some point. |
@1st1 ping |
|
||
def resume_reading(self): | ||
if not self._paused: | ||
raise RuntimeError('Not paused') | ||
self._paused = False | ||
if self._closing: | ||
return |
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 understand why you want to remove the exception from pause_reading
. But rising an error on trying to resume_reading
on a closed transport seems reasonable.
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 think resume_reading
is more important. from my experience pause_reading
is getting called from protocol, and protocol has access to transport object, but resume_reading
usually happen from higher level, from coroutine side. and coroutine usually doesn't have access to transport or protocol directly, it just writes to some kind of data stream.
Nikolay, could you please do the following and I'll merge this in:
|
@asvetlov Can you take a look at this one? |
Let's call it |
…s_reading(). Fixes issue #93. Implements python/cpython#528 asyncio change.
The PR branch is gone, the PR should be manually re-created -- as I did for #2269 |
Closing this in favour of #4914 |
…s_reading(). Fixes issue #93. Implements python/cpython#528 asyncio change.
PR for python/asyncio#488