# Return result:
return response['result']
else:
- raise Exception("Reader or writer missing.")
+ if writer is not None:
+ writer.close()
+ self.connection.closed += 1
+ # Open connection:
+ (r, w) = await asyncio.open_connection(self.hostname,
+ self.port,
+ ssl=self.ssl)
+ self.connection.opened += 1
+ # Read banner:
+ size_bytes = await r.readexactly(4)
+ size_int = struct.unpack('<i', size_bytes)[0]
+ message = await r.readexactly(size_int)
+ # Set reader and writer in data:
+ self.connection.reader = r
+ self.connection.writer = w
+ raise Exception("Reader or writer missing. Reopened.\n"
+ "Currently open contexts:"
+ f" {self.connection.contexts}\n"
+ "Connections opened since start: "
+ f" {self.connection.opened}\n"
+ "Connections closed since start: "
+ f" {self.connection.closed}")