Implementing API Timeouts and Retries in Python