122 @rtype bytes |
123 @rtype bytes |
123 """ |
124 """ |
124 data = b'' |
125 data = b'' |
125 self.connection.setblocking(False) |
126 self.connection.setblocking(False) |
126 try: |
127 try: |
127 data = self.connection.recv(length, socket.MSG_PEEK) |
128 with contextlib.suppress(OSError): |
128 except OSError: |
129 data = self.connection.recv(length, socket.MSG_PEEK) |
129 pass |
|
130 finally: |
130 finally: |
131 self.connection.setblocking(True) |
131 self.connection.setblocking(True) |
132 |
132 |
133 return data |
133 return data |
134 |
134 |