Long intervals during resource iteration can lead to issues

Đang mở
#141 0 bình luận 2 reaction 0 người được giao Xem trên GitHub

@AdrianAtZyte đang làm issue này rồi.

Từ ngày 25/9/2026.

  • #205 của @AdrianAtZyte — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu với điểm vào của quá trình thu thập tài nguyên được job.items.iter(count=take, meta='_key') sử dụng, và tái hiện trường hợp JSON với use_msgpack=False cùng độ trễ ba phút. Theo dõi cách các yêu cầu lặp giữ nguyên count trong quá trình truy xuất bị trì hoãn; hoàn thành khi iterator dừng ở giới hạn được yêu cầu thay vì vượt quá giới hạn đó, với hành vi này được bao phủ bởi các bài kiểm thử hiện có của repository nếu phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Hello.

Recently there was this issue https://github.com/scrapinghub/python-scrapinghub/issues/121 for which a batch read workaround was implemented. I am now experiencing from what I believe to be same or similar issue but now while using JSON instead of msgpack. Basically when I do for item in job.items.iter(..., count=X, ...): if there are long intervals during iteration the count can end up being ignored. I was able to reproduce it with the following snippet:

sh_client = ScrapinghubClient(APIKEY, use_msgpack=False)
take = 10_000
job_id = '168012/276/1'
for i, item in enumerate(sh_client.get_job(job_id).items.iter(count=take, meta='_key')):
    print(f'\r{i} ({item["_key"]})', end='')

    if i == 3000:
        print('\nsleeping')
        time.sleep(60*3)
    
    if i > take:
        print('\nWTF')
        break

With the sleep part removed the WTF section does not fire and the iterator stops on 168012/276/1/9999th item.

This seem to be more of a ScrapyCloud API platform problem but I am reporting it here to track nonetheless.

For now I am assuming resource/collections iteration is not robust if any delays are possible client side during retrieval (I haven't tested any other potential issues) and I will try either preloading all at once (.list()) or using .list_iter() when makes sense as a habit.

Ngôn ngữ chính
Python
Star
204
Fork
62
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của scrapinghub/python-scrapinghub

Tất cả issue của scrapinghub/python-scrapinghub

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.