def send_inputs(self, *input_args: Any, method: str = None, input_kwargs: Optional[Dict[str, Any]] = None, topic: str = 'default'): """Send inputs to be computed Args: *input_args (Any): Positional arguments to a function method (str): Name of the method to run. Optional input_kwargs (dict): Any keyword arguments for the function being run topic (str): Topic for the queue, which sets the topic for the result. """ # Make fake kwargs, if needed if input_kwargs is None: input_kwargs = dict() # Create a new Result object result = Result((input_args, input_kwargs), method=method) # Push the serialized value to the method server if self.use_pickle: result.pickle_data() self.outbound.put(result.json(exclude_unset=True), topic=topic) logger.info(f'Client sent a {method} task with topic {topic}')
def send_result(self, result: Result, topic: str = 'default'): """Send a value to a client Args: result (Result): Result object to communicate back topic (str): Topic of the calculation """ if self.use_pickle: result.pickle_data() self.outbound.put(result.json(), topic=topic)