I have some async websocket code that runs forever and gives me data on a zmq socket. On my "receiver" page, I have this code:
while True:
msg = zmqsocket.signal_recv()
new_msg = data_preparation_function(msg)
other_function(new_msg)
My data preparation function aggregates this data, and once every x messages yields an aggregated message that the other functions use do things.
My question is, should I rewrite the data_preparation_function using asyncio if the other_functions can't do anything if the first function hasn't finished running?
Since the zmq socket yields thousands of messages per second, and the other_functions take some time to run, I'm afraid of loosing data while the functions are running if I don't read it from the socket, hence I was considering doing everything async.
I'm using Python 3.7.7