0

我正在尝试建立一个疫苗可用性项目。我每 4 秒请求一次检查疫苗剂量,

response = requests.get(https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=770&date=)

有时我会遇到Connection Error. 我想在我的代码中添加重试功能,我知道那里有很多答案,但他们正在使用该库。我想构建自己的重试功能来了解核心机制并获得乐趣。

任何人都可以帮助它应该如何实施?

4

1 回答 1

0
import requests
import time
def foo():
    try:
        response = response.get("some URL")
    # you can modify exceptions as per your choice
    except Exception as e:
        time.sleep(30)
        foo()
于 2021-05-24T18:15:11.870 回答