Review thread safety of client/API/Evaluation context
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
Bắt đầu với các thành phần được liệt kê: provider/_registry.py, hook/init.py, api.py, _event_support.py, evaluation_context/init.py, transaction_context/init.py, client.py và provider/init.py. So sánh hành vi đồng thời của chúng với phần thảo luận Java SDK được liên kết. Công việc được xem là hoàn tất khi tạo các issue theo dõi tập trung cho công việc về tính an toàn luồng của API toàn cục, client và evaluation context được mô tả trong định nghĩa hoàn tất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Review the thread safety of the SDK to make sure there's no potential concurrency issues, particularly around state maintained in the global API object, clients, and evaluation context objects.
See here for a similar discussion in the Java SDK and others.
Background
Python's GIL is sometimes mistaken for making threading a non-issue (like Node's single-threaded model), but they're not the same. The GIL only makes individual bytecode operations atomic; compound operations like check-then-act or read-modify-write are not safe. Providers commonly run background threads for connection management and emit events from them, so these races aren't just theoretical.
Audit
Here's what we found. The only locks in the SDK today are in _event_support.py (and even those have some gaps). Everything else is unprotected.
ProviderRegistrysingleton (provider/_registry.py) - this is the big one. No locks at all.set_provider()andset_default_provider()have check-then-act patterns with side effects (initialize/shutdown), so concurrent calls can double-shutdown, lose providers, or initialize providers that never get registered.clear_providers()has a window where shut-down providers are still returned to callers.- Global
_hookslist (hook/__init__.py) -add_hooksdoes_hooks = _hooks + hookswhich is a read-concat-rebind; two concurrent calls can lose one set of hooks api.clear_providers()(api.py) - callsprovider_registry.clear_providers()then_event_support.clear()as two separate steps; event handlers still exist but providers are gone in between_event_support.py- has RLock (good), but immediate handler execution inadd_*_handlerruns outside the lock, andclear()acquires two separate locks non-atomically- Global
_evaluation_context(evaluation_context/__init__.py) - no lock; TOCTOU across the evaluation pipeline (context can change between read and use) - Global transaction context propagator (
transaction_context/__init__.py) - no lock; read-then-call-method races with propagator swap - Client instance state (
client.py) -self.hookshas the same lost-update pattern as global hooks;_assert_provider_statusreadsself.provideragain instead of using the reference captured earlier in the evaluation flow, so the status check can be for a different provider than the one actually used AbstractProvider._on_emit(provider/__init__.py) -emit()doesif hasattr(self, "_on_emit"): self._on_emit(...)which is a TOCTOU;detach()during shutdown can delete_on_emitwhile a background thread is between the check and the call
Definition of done
- issues created for thread safety of global API, client, and evaluation context
- Ngôn ngữ chính
- Python
- Star
- 113
- Fork
- 48
- Merge trung bình
- 23 giờ 52 phút
- Pull request đã merge (30 ngày)
- 20
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 open-feature/python-sdk
-
[BUG] before hooks do not receive the evaluation context returned by earlier before hooksCó thể đã có người làm @Ritinpaul đã nhận 52 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
open-feature/python-sdk#628 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
open-feature/python-sdk#627 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Spec v0.9.0 complianceĐang mởv0.9.0
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
open-feature/python-sdk#618 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Supply the bound domain to provider initializationCó thể đã có người làm @jonathannorris đã nhận 148 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
open-feature/python-sdk#615 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support isolated API instancesCó thể đã có người làm @marcozabel đã nhận 219 ngày trước. Đang mở
open-feature/python-sdk#584 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của open-feature/python-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue help wanted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
documentation good first issue help wanted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100