I have an async function my_func
that performs two operations: f
and g
. The f
operation sends data over a WebSocket and doesn’t return anything. The g
operation performs some computations and returns a value.
async def my_func(self, a: str, b: str) -> str:
await f(a, b) # sends data on websocket
out = g(a, b)
return out
The problem is that g
executes immediately after f
is called, without waiting for the WebSocket operation to complete. I need g
to execute only after f
has finished sending the data over the WebSocket.
How can I modify this code to make g
wait for the async operation f
to complete before executing?
Please note that f
doesn’t return anything, so I can’t use the standard await
on its return value.