econchick / econchick/mayhem

There is an error in the example code

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
302
Forks
43
PR merge metrics
No merged PRs in 30d

Description

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:

```sh
$ 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`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.