X-Git-Url: https://plomlompom.com/repos/?p=plomrogue2-experiments;a=blobdiff_plain;f=new2%2Fplomrogue%2Fio_tcp.py;fp=new2%2Fplomrogue%2Fio_tcp.py;h=b030f1b9f1c98332084763812bf152666004bb7a;hp=f0a49a97dad632fa4f3dc10770432f424ba90155;hb=81d69377ef8309ffdfda6a744a7375006521f29e;hpb=29930c6b44e4b1d5b60446c0b83059588a9e2d9e diff --git a/new2/plomrogue/io_tcp.py b/new2/plomrogue/io_tcp.py index f0a49a9..b030f1b 100644 --- a/new2/plomrogue/io_tcp.py +++ b/new2/plomrogue/io_tcp.py @@ -6,6 +6,7 @@ socketserver.TCPServer.allow_reuse_address = True +from plomrogue.errors import BrokenSocketConnection class PlomSocket: def __init__(self, socket): @@ -32,7 +33,6 @@ class PlomSocket: """ - from plomrogue.errors import BrokenSocketConnection escaped_message = '' for char in message: if char in ('\\', '$'): @@ -77,7 +77,11 @@ class PlomSocket: data = b'' msg = b'' while True: - data = self.socket.recv(1024) + try: + data = self.socket.recv(1024) + except OSError as err: + if err.errno == 9: # "Bad file descriptor", when connection broken + raise BrokenSocketConnection if 0 == len(data): break for c in data: