Rate-limit handling to count requests
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reading BaseDAVClient._rate_limit_sleep_seconds() and the rate-limit decorator setup in tests/test_caldav.py around line 1412. Compare the existing reactive client behavior with the test framework’s fixed-delay behavior, then decide where request counting belongs. Done means the chosen approach respects the declared interval and count without delaying requests while budget remains.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Currently the rate-limit throttling is done very simple - if it's allowed, say, to send 30000 requests within a 30000 second window, it will sleep 1s between each request.
Two alternative methods should be considered:
- Send 30000 requests without any throttling, then sleep out the window.
- Send the first request without any throttling, then add a progressingly growing delay so that there will never be a long complete halt when the quota has been reached.
The description below was AI-generated and seems to follow the first
method suggested above.
There are two separate pieces of rate-limit machinery today, and neither counts
requests.
The client is purely reactive. BaseDAVClient._rate_limit_sleep_seconds()
only ever runs after the server has answered 429 (or 503 with Retry-After).
It sleeps Retry-After, or default_sleep, capped by max_sleep, and retries.
Nothing tracks how many requests have been sent, so the client walks into the
throttle every time and then waits it out.
The test framework throttles pre-emptively, with a fixed delay per request.
tests/test_caldav.py around line 1412:
foo = self.is_supported("rate-limit", dict)
if foo.get("enable"):
rate_delay = foo.get("interval", 0) / foo.get("count", 1)
self.caldav.request = _delay_decorator(self.caldav.request, t=rate_delay)
So a server declaring interval: 300, count: 1500 gets 300 / 1500 = 0.2
seconds of sleep before every request, including the first, when the whole
budget is still unspent. A run that makes a few thousand requests pays minutes
for it. For ecloud, which declares interval: 2, count: 1, it is 2 seconds per
request.
What it should do instead
Count. A token bucket, or simply a deque of the timestamps of requests inside
the window:
- under budget → send immediately, no sleep at all;
- budget spent → sleep exactly long enough for the oldest request in the window
to age out, not a fixed slice.
With 1500 per 300s that means the first 1500 requests go through at full speed
and only a run that genuinely exceeds the server's budget ever waits.
Where it belongs
Arguably in the client rather than the test framework, so that real users get it
too: a client that knows a server's published limits can stay under them instead
of discovering them through 429s. The test framework's decorator could then go
away. Deciding that is part of the issue - the rate-limit feature already
carries interval and count, and nothing outside the test suite reads them.
Noticed while adding a rate-limit declaration for OX (interval 300, count
1500), which switched that 0.2-second-per-request delay on for the whole OX test
run.
- Ngôn ngữ chính
- Python
- Star
- 412
- Fork
- 113
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 41
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-caldav/caldav
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
python-caldav/caldav#687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
python-caldav/caldav#774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
python-caldav/caldav#769 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 50/100
python-caldav/caldav#765 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
python-caldav/caldav#763 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python-caldav/caldav
Issue tương tự
-
approved Good First Issue scope: docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
hiero-ledger/hiero-sdk-python#2730 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
wemake-services/wemake-django-template#3178 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
md/asciidoc/csv: an explicit `encoding="utf-8"` keeps a leading BOM, the auto-detect path drops itĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
docling-project/docling#4846 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
neurostuff/NiMARE#1181 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pytest-dev/pytest#15180 ·
Maintainer thường phản hồi trong vòng 1 ngày