https://roguelynn.com/words/asyncio-exception-handling/
When the code is corrected to handle exceptions that may be raised by save or restart_host functions, the sample output is given as:
$ python part-3/mayhem_5.py
14:58:15,750 INFO: Consumed PubSubMessage(instance_name='cattle-jmtv')
14:58:15,981 INFO: Saved PubSubMessage(instance_name='cattle-jmtv') into database
14:58:15,981 ERROR: Retrying for failure to restart: cattle-jmtv.example.net
14:58:16,873 INFO: Restarted cattle-hukm.example.net
14:58:16,903 INFO: Done. Acked PubSubMessage(instance_name='cattle-jmtv')
However, the handle_message function was only changed to not raise if one of the tasks passed to asyncio.gather itself raises, and the handling logic only logs a message. So once a RestartFailed exception is raised, we do not expect the same coroutine to eventually resume and then log the line INFO: Restarted cattle-hukm.example.net
https://roguelynn.com/words/asyncio-exception-handling/
When the code is corrected to handle exceptions that may be raised by
saveorrestart_hostfunctions, the sample output is given as:However, the
handle_messagefunction was only changed to not raise if one of the tasks passed toasyncio.gatheritself raises, and the handling logic only logs a message. So once aRestartFailedexception is raised, we do not expect the same coroutine to eventually resume and then log the lineINFO: Restarted cattle-hukm.example.net