I am using Python 3.4.3.
I have an application that uses a task to continuously read data from a serial device. This task is invoked with "loop.run_until_complete". While this task collecting and interpreting data, it may fire off other tasks. In addition, commands are also arriving from method calls from a user API that fire off other tasks with "run_until_complete". The application runs forever until the user hits "Control C".
Is there a way for me to cleanly exit (no exceptions or errors) by:
1. Getting a list of currently running tasks.
2. Iterate through that list to cancel the tasks.
3. Test that the tasks are cancelled.
4. Exit the program.
Perhaps there are alternatives to accomplish the same thing and I would like to know how to accomplish the above.
If there is, I still would like to know how to get a list of currently running tasks and to cancel those tasks.