3 ms·
I am working on a crawler that uses async/await, and from experimentation the list is: except (aiohttp.ClientError, aiohttp.DisconnectedError, aiohttp.HttpProc
by greglindahl 10y ago
I am working on a crawler that uses async/await, and from experimentation the list is:
except (aiohttp.ClientError, aiohttp.DisconnectedError, aiohttp.HttpProcessingError, aiodns.error.DNSError, asyncio.TimeoutError, RuntimeError) as e:
I want to continue running no matter what, so I also have an "except Exception", but I have better logging now that I know what the known vs. unknown exceptions are.
- kstrauser 10y agoMy pattern on this stuff is to initially write: try: do_something() except ExpectedException: handle_it() except OtherKnownException: handle_that_too() except Exception as exc: log.exception('New kind of error just happened') handle_fallback()
- greglindahl 10y agoYes, that's basically what I'm doing.