Skip to content

Commit

Permalink
Silence "No route to host" and "Connection timedout" errors when clie…
Browse files Browse the repository at this point in the history
…nts dissapear
  • Loading branch information
hno committed Mar 14, 2014
1 parent c62ac23 commit 4495b6d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion networkserver.py
Expand Up @@ -23,10 +23,13 @@
from time import time
import traceback
from util import ScheduleDict, WithNoop, tryErr
from errno import EHOSTUNREACH, ETIMEDOUT

EPOLL_READ = select.EPOLLIN | select.EPOLLPRI | select.EPOLLERR | select.EPOLLHUP
EPOLL_WRITE = select.EPOLLOUT

_DISCONNECTED = frozenset((EHOSTUNREACH,ETIMEDOUT))

class SocketHandler:
ac_in_buffer_size = 4096
ac_out_buffer_size = 4096
Expand All @@ -46,7 +49,12 @@ def handle_read(self):
try:
data = self.recv (self.ac_in_buffer_size)
except socket.error as why:
self.handle_error()
# This silences some additional expected socket errors
# not automatically dealt with by asyncore.
if why.args[0] not in _DISCONNECTED:
self.handle_error()
else:
self.handle_close()
return

if self.closeme:
Expand Down

0 comments on commit 4495b6d

Please sign in to comment.