Folks, can we stop the testy interaction?

I'm personally confused how a protocol can require any kind of exchange on
shutdown. Surely the clients can't rely on this exchange? Because it's
always possible that the server crashes (or a network partition appears)
without having this exchange. And if the process crashes, TCP should have
enough of a handshake to tell the remote end the socket has closed
immediately -- there shouldn't be any timeout involved here. So perhaps
this requirement (if it is in the spec) is just encouraging poorly written
clients that will misbehave or hang without this designated closing
exchange? (Or is it a work-around for a known browser issue?)

I also believe asyncio.AbstractServer shouldn't be subclassed; in general
subclassing asyncio classes is frowned upon unless explicitly documented,
and this class isn't documented at all (but even if it were, it would only
be meant for type checks, not to subclass).

I do have to agree with others on the thread that doing something special
for all open client connections seems to be an application-level thing.
Also, how do you detect this server shutdown? Is it a signal?

On Mon, Aug 10, 2015 at 2:59 PM, Aymeric Augustin <
[email protected]> wrote:

> On 10 août 2015, at 11:38, Ludovic Gasc <[email protected]> wrote:
>
> I don't know all implementation details, however, we use on production for
> several daemons this implementation:
> http://aiohttp.readthedocs.org/en/latest/web.html#websockets
>
> Yes, it’s a lower-level alternative with a more verbose API. It was
> written after I released websockets.
> FYI here’s a quick comparison of echo servers written with each library:
>
> # websockets @asyncio.coroutine def handler(websocket, path): while True:
> data = yield from websocket.recv() if message is None: break yield from
> websocket.send(data) # aiohttp @asyncio.coroutine def
> websocket_handler(request): ws = web.WebSocketResponse() ws.start(request)
> while True: msg = yield from ws.receive() if msg.tp ==
> aiohttp.MsgType.text: ws.send_str(msg.data) # unsure about this one as
> MsgType isn't documented elif msg.tp == aiohttp.MsgType.bytes:
> ws.send_str(msg.data) elif msg.tp == aiohttp.MsgType.close: break elif
> msg.tp == aiohttp.MsgType.error: break return ws
>
> About your specific problem, I'm not sure it's implemented in aiohttp
> because it's remember me something, however, when we stops the daemon, we
> use the bidirectional communication property of WebSockets to send a signal
> to the Web browsers to force disconnections and use another server, to try
> to be the most invisible at end user level.
>
>
> In other words you’ve implemented a custom application-level closing
> message because the library you’re using doesn’t implement the
> protocol-level closing handshake. Truth be said, neither did mine until a
> few days ago ;-)
>
> --
> Aymeric.
>
>
>


-- 
--Guido van Rossum (python.org/~guido)

Reply via email to