Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Functions like get_data are inherently not thread safe

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

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
30/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Start by reading the implementations of get_data and save, then examine how shelve is used during concurrent operations. Define and test the proposed option to disable automatic disk saving and provide a manual save step; done means concurrent use avoids unprotected persistence and the final state can be saved consistently.

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

Mô tả

The current implementation of get_data directly calls save, which introduces a risk when used in multithreaded contexts. The disk I/O performed by save is not protected, but locking around it has serious performance implications.

In my own private implementation of a REST API client for PokeAPI in python (sorry just found out about this project), I solved this by separating in‑memory caching from disk persistence. My approach was:

  • Keep an in‑memory cache updated freely across threads.
  • Disable automatic disk saving during concurrent operations.
  • Manually invoke a disk save step once threads have finished, ensuring serialization and consistency.

One note is it would likely involve not using shelve as I believe that is not thread safe. But other features may be more suited.

With approval, I am willing to begin migrating my code to use pokebase, implement and test a option to disable auto‑save and give manual control.

Ngôn ngữ chính
Python
Star
361
Fork
58
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 PokeAPI/pokebase

Tất cả issue của PokeAPI/pokebase

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.