I am writing a python client that sends requests to our inhouse servers. These requests can go through different connections and need to be somewhat balanced. So far so good, I have the logic to send different requests to alternating backend connections.
My problem now is: If one of those connections breaks down for any reason there is a retry logic implemented. Now this retry always sends to the connection it was initialised with. It is so deep in the requests library that I do not see a way to implement load balancing here without reimplementing a huge chunk of the requests library.
I tried subclassing HTTPSConnectionPool and HTTPAdapter but any attempt to get the information about alternate possible connections (Like for example a special url scheme "myhttp://host1!host2!.../path") breaks other parts of the requests library.
Am I missing something or is ther currently just no managably easy way to have retry do load balancing?
I am using python 3.7 and requests 2.24.0