named-data / python-ndn

An NDN client library with AsyncIO support in Python 3
https://python-ndn.readthedocs.io/en/latest
Apache License 2.0
24 stars 17 forks source link

NDNApp stuck when after_start() throws exception #5

Closed JonnyKong closed 4 years ago

JonnyKong commented 4 years ago

In NDNApp.run_forever(), if the after_start continuation throws an exception, the event loop might get stuck. I'm opening this issue so that you don't forget.

As we discussed last week, one quick fix is to change: https://github.com/zjkmxy/python-ndn/blob/16cb6de6537a334ada2e76c2a43b156269edfed3/src/ndn/app.py#L239-L240 to:

if after_start:
    try:
        await after_start
    except Exception as exc:
        self.face.shutdown()
        raise exc from None
zjkmxy commented 4 years ago

Thank you for opening this. It's fixed on schema branch but not yet on the master. I will do this ASAP.

https://github.com/zjkmxy/python-ndn/blob/cac66e7818857e633228bfc57c192b6f079419e5/src/ndn/app.py#L236-L244