mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-74116: Allow multiple drain waiters for asyncio.StreamWriter (GH-94705)
(cherry picked from commit e5b2453e61)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
280130f035
commit
f60bbf0a93
3 changed files with 36 additions and 19 deletions
|
|
@ -801,6 +801,25 @@ def test_streamreaderprotocol_constructor_use_global_loop(self):
|
|||
self.assertEqual(cm.warnings[0].filename, __file__)
|
||||
self.assertIs(protocol._loop, self.loop)
|
||||
|
||||
def test_multiple_drain(self):
|
||||
# See https://github.com/python/cpython/issues/74116
|
||||
drained = 0
|
||||
|
||||
async def drainer(stream):
|
||||
nonlocal drained
|
||||
await stream._drain_helper()
|
||||
drained += 1
|
||||
|
||||
async def main():
|
||||
loop = asyncio.get_running_loop()
|
||||
stream = asyncio.streams.FlowControlMixin(loop)
|
||||
stream.pause_writing()
|
||||
loop.call_later(0.1, stream.resume_writing)
|
||||
await asyncio.gather(*[drainer(stream) for _ in range(10)])
|
||||
self.assertEqual(drained, 10)
|
||||
|
||||
self.loop.run_until_complete(main())
|
||||
|
||||
def test_drain_raises(self):
|
||||
# See http://bugs.python.org/issue25441
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue