-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Concurrent drains #1915
Concurrent drains #1915
Conversation
@@ -125,7 +128,18 @@ def drain(self): | |||
yield from w.drain() | |||
""" | |||
if self._protocol.transport is not None: | |||
yield from self._protocol._drain_helper() | |||
if self._is_drain: | |||
fut = asyncio.Future(loop=self._loop) |
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.
self._loop.create_future()
I guess
self._is_drain = False | ||
if self._drain_waiters: | ||
fut = self._drain_waiters.popleft() | ||
fut.set_result(None) |
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 same "deadlock" issue (a,b) can happen here: if future on line 134 is cancelled then other task that
sets result for next waiter will do nothing and all other futures will be in _drain_waiters
forever.
a: bugs.python.org/issue27585
b: python/asyncio#393 and propbably python/cpython#1031
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 cancellation tests should be added as well.
@@ -125,7 +128,18 @@ def drain(self): | |||
yield from w.drain() | |||
""" | |||
if self._protocol.transport is not None: | |||
yield from self._protocol._drain_helper() | |||
if self._is_drain: | |||
fut = asyncio.Future(loop=self._loop) |
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.
can't we use same future for all callers?
The code is outdated |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
asyncio doesn't support concurrent
.drain()
calls (#1886 (comment))This PR proposes a workaround for the issue.