New submission from Metathink:

While trying to break some code in a project using asyncio, I found that under 
certain circumstances, asyncio.StreamWriter.drain raises an AssertionError.

1. There must be a lot of concurrent uses of "await writer.drain()"
2. The server on which we send data must be public, no AssertionError occurs 
while connected to 127.0.0.1

Task exception was never retrieved
future: <Task finished coro=<flooding() done, defined at client.py:10> 
exception=AssertionError()>
Traceback (most recent call last):
  File "client.py", line 12, in flooding
    await writer.drain()
  File "/usr/local/lib/python3.6/asyncio/streams.py", line 333, in drain
    yield from self._protocol._drain_helper()
  File "/usr/local/lib/python3.6/asyncio/streams.py", line 208, in _drain_helper
    assert waiter is None or waiter.cancelled()
AssertionError

I don't know much about how the drain function is working or how networking is 
handled by the OS, but I'm assuming that I'v reached some OS limitation which 
trigger this AssertionError.

I'm not sure how I'm supposed to handle that. Am I supposed to add some 
throttling because I should not send too much data concurrently? Is this 
considered as a bug? Any explanations are welcome.

Here some minimal client and server exemples if you want to try to reproduce it:
- Server: https://pastebin.com/SED89pwB
- Client: https://pastebin.com/ikJKHxi9

Also, I don't think this is limited to python 3.6, I'v found this old issue on 
the aaugustin's websockets repo which looks the same: 
https://github.com/aaugustin/websockets/issues/16

----------
components: asyncio
messages: 290690
nosy: metathink, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.StreamWriter.drain raises an AssertionError under heavy use
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29930>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to