Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Make pause/resume_reading idepotent and no-op for closed transports #528

wants to merge 1 commit into from

Conversation

fafhrd91
Copy link
Contributor

@fafhrd91 fafhrd91 commented Mar 6, 2017

@mention-bot
Copy link

@fafhrd91, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Haypo, @1st1, @tiran, @asvetlov and @benjaminp to be potential reviewers.

@fafhrd91
Copy link
Contributor Author

fafhrd91 commented Mar 6, 2017

@1st1

logger.debug("%r resumes reading", self)
elif not self._paused:
if self._loop.get_debug():
logger.debug("%r not paused", self)
Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@fafhrd91 fafhrd91 changed the title Make pause/resume_reading idepotent and no-op during closing Make pause/resume_reading idepotent and no-op for closed transports Mar 7, 2017
@fafhrd91
Copy link
Contributor Author

fafhrd91 commented Mar 7, 2017

updated debug messages

@1st1 do we still need to support _SelectorSslTransport (legacy)?

@1st1
Copy link
Member

1st1 commented Mar 7, 2017

@1st1 do we still need to support _SelectorSslTransport (legacy)?

_SelectorSslTransport is only used in 3.4, right? If yes, then we don't need to care about it.

@fafhrd91
Copy link
Contributor Author

fafhrd91 commented Mar 7, 2017

that depends on availability of ssl's MemoryBIO. Do you think we should remove code related to old versions of python?

@1st1
Copy link
Member

1st1 commented Mar 7, 2017

that depends on availability of ssl's MemoryBIO.

Isn't it always available in 3.5/3.6?

Do you think we should remove code related to old versions of python?

Yeah, I was planning to do a cleanup myself at some point.

@fafhrd91
Copy link
Contributor Author

@1st1 ping


def resume_reading(self):
if not self._paused:
raise RuntimeError('Not paused')
self._paused = False
if self._closing:
return
Copy link
Member

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.

Copy link
Contributor Author

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.

@1st1
Copy link
Member

1st1 commented Oct 11, 2017

Nikolay, could you please do the following and I'll merge this in:

  1. Add ReadTransport.is_paused() method (and implement it for all transports.
  2. Rebase & add a NEWS entry using blurb.

@1st1
Copy link
Member

1st1 commented Nov 17, 2017

@asvetlov Can you take a look at this one?

@1st1
Copy link
Member

1st1 commented Nov 17, 2017

Add ReadTransport.is_paused() method (and implement it for all transports.

Let's call it Transport.is_reading().

1st1 added a commit to MagicStack/uvloop that referenced this pull request Nov 17, 2017
@asvetlov
Copy link
Contributor

The PR branch is gone, the PR should be manually re-created -- as I did for #2269
U have an intention to work on it this weekend.

@asvetlov asvetlov self-assigned this Nov 17, 2017
@1st1
Copy link
Member

1st1 commented Dec 18, 2017

Closing this in favour of #4914

@1st1 1st1 closed this Dec 18, 2017
Olaf1022 pushed a commit to Olaf1022/Ultra-fast-asyncio that referenced this pull request Aug 13, 2023
…s_reading().

Fixes issue #93.
Implements python/cpython#528 asyncio change.
Sign up for free to 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.

6 participants