How to use StreamServer handle connection lost elegantly?

22 views
Skip to first unread message

Xiaochen Cui

unread,
Feb 28, 2018, 10:32:03 PM2/28/18
to gevent: coroutine-based Python network library
I write a server use StreamServer handle income packages.

Here comes some code snippets in handle function:

while True:
    message = sock.recv(2048)
    ...


But when client close connection initiative, the exception "error: [Errno 54] Connection reset by peer" raise.

I wander how we handle connection lost elegantly?

Grady Player

unread,
Feb 28, 2018, 10:46:27 PM2/28/18
to gev...@googlegroups.com
You haven’t given us much to go on, but you can wrap in try/except then try to recover by reopening connections or whatever is appropriate( we don’t have your application code ).

Grady


Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "gevent: coroutine-based Python network library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gevent+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages