Maybe I'm using asyncio improperly but currently I have a class that I'm writing that acts as the client. I'm trying to expose the API to it so that I'm able to use it like
client = ClientClass()
try:
client.start()
client.some_message_method()
client.other_message_method()
except KeyboardInterrupt:
client.stop()
Now the client, would be interacted with by other code that is synchronous so that may be my problem and the calls to other methods may not come immediately after start(),
so the start method would create the connection, send a logon message to the server and then send the heartbeats at the set intervals (resetting the interval when a different method is called.)
With coroutines I was able to run them with loop.run_until_complete and then return the response messages to the synchronous code. With tasks though there doesn't seem to be a way.