python: raise exception when for repeated ConnectionErrors
This situation led to
UnboundLocalError: local variable 'response' referenced before assignment
while attempting to return the not-yet-set response object.
Complements: 5572bff73596f0e96534bbd668f0dc35a9b077d3
Fixes: #2235
Relates: #2218