Waiting for a task to complete after KeyboardInterrupt in asyncio
问题 I'm trying to understand how does asyncio work. In my scenario client makes a tcp connection to the server, sends a login string, if authenticated - receives a stream of chars. Finally on KeyboardInterrupt sends logoff string to the server and hapilly disconnects. Currently I'm stuck on the final part as my logoff method/task is destroyed before it has a chance to complete. ^CTask was destroyed but it is pending! source_traceback: Object created at (most recent call last): File "tst.py", line