[issue27392] Add a server_side keyword parameter to create_connection

Jim Fulton report at bugs.python.org
Sun Jun 26 12:05:17 EDT 2016


New submission from Jim Fulton:

The event loop create_connection method can take a socket to create a connection on an existing socket, including sockets obtained via an external listener.  If an SSL context is provided, however, it assumes it's creating a client connection, making it impossible to use it in a server.

I've recently ported ZEO to asyncio. My original implementation used a separate thread for each connection and a thread for listening for connections.  I think there are cases where this makes a lot of sense.  Blocky operations only affect one client and, IMO, using an asynchronous model can simplify networking code even when there's only one connection. Unfortunately, this didn't work on Linux with SSL due to issues with SSL and non-blocking sockets. (Oddly, it worked fine on Mac OS X.)

I've switched my code to use create_server, but this has led to stability problems.  Beyond http://bugs.python.org/issue27386, I'm seeing a lot of test instability.  I can't get through the ZEO tests without some test failing, although the tests pass when run individually. I suspect that this is due to a problem in my error handling, asyncio's error handling, or likely both.

Note that the ZEO test suite is pretty ruthless, doing whatever they can to break ZEO servers and clients.

I have a version of my multi-threaded code that monkey-patches loop instances to pass server_side=True to _make_ssl_transport.  With that awful hack, I can use an external listener and tests usually run without errors. :)

I'd be more than happy to create a PR that adds this option (including test and docs). Please just give me the word. :)

----------
components: asyncio
messages: 269293
nosy: gvanrossum, haypo, j1m, yselivanov
priority: normal
severity: normal
status: open
title: Add a server_side keyword parameter to create_connection
type: enhancement
versions: Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27392>
_______________________________________


More information about the Python-bugs-list mailing list