I currently have a program structured like this:
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()
The network I/O currently uses sockets and select, but I want to rewrite it to use the asyncio library. I think I understand how to make a simple asyncio program, the idea seems to be that when you want to do some I/O, you yield from a function that does it, so when the main loop gets a new client, it does yield from accept_client(), and when that client receives information it does yield from read_information(), and so on. However, I can't work out how to combine this with other parts of the program.
asyncio.