Currently, I have a structure like:
set_up_everthing()
while True:
if new_client_ready():
connect_new_client()
for client in clients:
if client.is_ready():
get_input_from(client)
update_program_state_based_on_input()
for client in clients:
if client.is_ready():
send_output_to(client)
clean_up()
Network I / O currently uses sockets and selects, but I want to rewrite it to use the asyncio library. I think that I understand how to make a simple asintio program, the idea is that when you want to do some I / O, you yield fromperform a function, so when the main loop receives a new client, it does yield from accept_client(), and when that client receives information he does yield from read_information()and so on. However, I cannot figure out how to combine this with other parts of the program.
source
share