async def readexactly(self, n): try: return await super().readexactly(n) except IncompleteReadError as err: message = ("Network read incomplete (received {} of {} " "bytes)".format(len(err.partial), err.expected)) log.debug("[#%04X] S: <CLOSE>", self.local_address.port_number) Breakable.set_broken(self) raise BoltConnectionBroken(message, self.remote_address) from err except OSError as err: log.debug("[#%04X] S: <CLOSE> %d %s", err.errno, strerror(err.errno)) Breakable.set_broken(self) raise BoltConnectionBroken("Network read failed", self.remote_address) from err
def _assert_open(self): if self.closed: raise BoltConnectionClosed("Connection has been closed", self.remote_address) if self.broken: raise BoltConnectionBroken("Connection is broken", self.remote_address)
async def drain(self): try: await super().drain() except OSError as err: log.debug("[#%04X] S: <CLOSE> (%s)", self.local_address.port_number, err) Breakable.set_broken(self) raise BoltConnectionBroken("Network write failed", self.remote_address) from err