Are there ways to mitigate errors when using an API to communicate to a website via Python requests module?

Viewed 25

I have a program that communicates to a website through an API and uses the python requests module. I am not sure how specific my error is to my problem; however, I want to know what I can do to mitigate errors such as: requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Another error that recently appeared is: HTTPSConnectionPool(host='my-url.com', port=443): Max retries exceeded with url: /v1/some-directory/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000243FAAA2650>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

I get these errors at random times and I am not sure what the source could be. Are there any general best practices to implement when preventing these errors with Python?

0 Answers
Related