Some help on this intended behavior -- do stuff after actor method returns

I would like to achieve the following behavior in Ray.

I have an actor X (threaded actor with concurrency = 2) with two methods, say A and B. Another actor Y might want to call its A method.

What I would like to do, is that when Y invokes X’s A method, X returns something to Y and in the background starts to do B. The following way, would not work:

def A:
return X

Because it would call B before the return, whereas I want the execution of B to happen after A has returned. In essence I want the process executing A to return something to Y so that Y thinks the function has returned, but in reality keeping executing some code locally.

Please let me know if I need to be clearer in problem description.