def __init__(self, rpc_connection, stream_connection): self._types = Types() self._rpc_connection = rpc_connection self._rpc_connection_lock = threading.Lock() self._stream_connection = stream_connection self._request_type = self._types.as_type('KRPC.Request') self._response_type = self._types.as_type('KRPC.Response') # Set up the main KRPC service self.krpc = KRPC(self) services = self.krpc.get_services().services # Create class types #TODO: is this needed?!? #for service in services: # for procedure in service.procedures: # try: # name = Attributes.get_class_name(procedure.attributes) # self._types.as_type('Class(' + service.name + '.' + name + ')') # except ValueError: # pass # Set up services for service in services: if service.name != 'KRPC': setattr(self, _to_snake_case(service.name), create_service(self, service)) # Set up stream update thread if stream_connection is not None: self._stream_thread_stop = threading.Event() self._stream_thread = threading.Thread( target=krpc.stream.update_thread, args=(stream_connection, self._stream_thread_stop)) self._stream_thread.daemon = True self._stream_thread.start() else: self._stream_thread = None