I am writing a python program that is supposed to receive commands remotely, open a TCP connection locally (but not limited to localhost), and report the result.

I was looking for list of possible exceptions that can be thrown by asyncio.open_connection(...) but there seems to be nothing in the documentation at all. Where could I find such list? It is necessary to handle all exceptions that could possibly occur in order to report exception back to the command source, should an exception occur.

2 Replies 2

https://github.com/python/cpython/blob/main/Lib/asyncio/base_events.py#L1060 might be a place to start and/or https://github.com/python/cpython/blob/main/Lib/asyncio/exceptions.py though if you wanted to be sure to catch all/any exception then you just catch except Exception as e:

Thank you. I am kind of surprised it has to be distilled from the source code while official documentation completely ignores this. But it is not a topic to be discussed here :)

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.