Request timeouts are handled incorrectly, and will result in an exception of local variable 'response' referenced before assignment.
As a timeout will cause a requests.Timeout exception on the first line of the "try" block, the subsequent exception handler has response undefined.
A better way would probably be to handle the "timeout" exception seperately - or define response before the try block and check if it's defined in the exception handler.
Request timeouts are handled incorrectly, and will result in an exception of
local variable 'response' referenced before assignment
.As a timeout will cause a
requests.Timeout
exception on the first line of the "try" block, the subsequent exception handler has response undefined.A better way would probably be to handle the "timeout" exception seperately - or define response before the try block and check if it's defined in the exception handler.
Relevant code:
https://github.com/man-c/pycoingecko/blob/8b7a8451cc8911eff5a7f268c885da4bc1570c3f/pycoingecko/api.py#L23-L38
Unfortunately, reproducing this reliably is quite hard, as timeouts are ... in general not easy to reproduce.