Closed AndreLouisCaron closed 6 years ago
If it's any help, I worker around this problem by setting no_delay=False
.
I'm not sure why there is a problem with this, and maybe we need to draw attention to asyncio maintainers, but my spider sense tells me this is somewhat of an anti-pattern with a proactor:
def _set_nodelay(self, value):
...
transport.pause_reading()
raw_sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, flag)
transport.resume_reading()
Because of the nature of (true) asynchronous I/O, there's no way you can guarantee that I/O operations will not complete between the calls to .pause_reading()
and .resume_reading()
.
FYI, as of Python 3.6, the TCP_NODELAY
option is automatically set on all TCP connections (see python/asyncio#373).
It's still not the default on the proactor event loop though :-/
Thanks for updates! no_delay
option is deprecated on PyMySQL as result we deprecated it too, but looks like we need to keep it until asyncio fix this issue.
For posterity, this was a Python bug that was fixed in Python 3.7 and 3.6.6.
@Harmon758 Can you provide a link to the Python bug tracker? Would really appreciate :-)
I did so as a Markdown link, but here it is again: https://bugs.python.org/issue26819 Unless this isn't what you meant?
Hi there!
I hit an issue when trying to use
aiomysql
with theProactorEventLoop
on Windows. This is pretty much a show stopper for me given the limitations of the (default)SelectorEventLoop
on Windows (bad performance, no pipes, no subprocesses, 512 socket limit).I'm trying out the library with this example slightly adapted from the one in the documentation:
Here is the output when using the default event loop:
Here is the output when uncommenting the two lines that select the
ProactorEventLoop
:In addition to the unexpected output, the Python process hangs, does not respond to CTRL-C and I need to explicitly terminate it.