René's URL Explorer Experiment


Title: Review thread safety of client/API/Evaluation context · Issue #96 · open-feature/python-sdk · GitHub

Open Graph Title: Review thread safety of client/API/Evaluation context · Issue #96 · open-feature/python-sdk

X Title: Review thread safety of client/API/Evaluation context · Issue #96 · open-feature/python-sdk

Description: 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 Ja...

Open Graph Description: 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...

X Description: 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....

Opengraph URL: https://github.com/open-feature/python-sdk/issues/96

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Review thread safety of client/API/Evaluation context","articleBody":"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.\n\nSee [here](https://github.com/open-feature/java-sdk/issues/64) for a similar discussion in the Java SDK and others.\n\n## Background\n\nPython'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.\n\n## Audit\n\nHere'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.\n\n- **`ProviderRegistry` singleton** (`provider/_registry.py`) - this is the big one. No locks at all. `set_provider()` and `set_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.\n- **Global `_hooks` list** (`hook/__init__.py`) - `add_hooks` does `_hooks = _hooks + hooks` which is a read-concat-rebind; two concurrent calls can lose one set of hooks\n- **`api.clear_providers()`** (`api.py`) - calls `provider_registry.clear_providers()` then `_event_support.clear()` as two separate steps; event handlers still exist but providers are gone in between\n- **`_event_support.py`** - has RLock (good), but immediate handler execution in `add_*_handler` runs outside the lock, and `clear()` acquires two separate locks non-atomically\n- **Global `_evaluation_context`** (`evaluation_context/__init__.py`) - no lock; TOCTOU across the evaluation pipeline (context can change between read and use)\n- **Global transaction context propagator** (`transaction_context/__init__.py`) - no lock; read-then-call-method races with propagator swap\n- **Client instance state** (`client.py`) - `self.hooks` has the same lost-update pattern as global hooks; `_assert_provider_status` reads `self.provider` again 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\n- **`AbstractProvider._on_emit`** (`provider/__init__.py`) - `emit()` does `if hasattr(self, \"_on_emit\"): self._on_emit(...)` which is a TOCTOU; `detach()` during shutdown can delete `_on_emit` while a background thread is between the check and the call\n\n## Definition of done\n\n- [ ] issues created for thread safety of global API, client, and evaluation context","author":{"url":"https://github.com/toddbaert","@type":"Person","name":"toddbaert"},"datePublished":"2023-04-18T13:33:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/96/python-sdk/issues/96"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:efa45860-c3c9-08f8-5abe-8665f851d4e4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA1CE:36DB52:1411B55:1CF9024:6A4CDA2B
html-safe-noncedcf4eb3ad8393d80fe78777137068a5cf8a0c300e95f1d08942fb6360d3f0212
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUNFOjM2REI1MjoxNDExQjU1OjFDRjkwMjQ6NkE0Q0RBMkIiLCJ2aXNpdG9yX2lkIjoiNjYwOTE2ODEyNDM3NjU3MDQxMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacf8923b77c4f00a211f3c48684f1b35a6044c323ca57e33bd11317586e4fdef7c
hovercard-subject-tagissue:1673147756
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/open-feature/python-sdk/96/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c2b62d68a5735eef3c2962143fd34ee3b3cd76030b3b606bcd42a4ff0a2f6c07/open-feature/python-sdk/issues/96
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c2b62d68a5735eef3c2962143fd34ee3b3cd76030b3b606bcd42a4ff0a2f6c07/open-feature/python-sdk/issues/96
og:image:altReview 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...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametoddbaert
hostnamegithub.com
expected-hostnamegithub.com
None299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8
turbo-cache-controlno-preview
go-importgithub.com/open-feature/python-sdk git https://github.com/open-feature/python-sdk.git
octolytics-dimension-user_id99483952
octolytics-dimension-user_loginopen-feature
octolytics-dimension-repository_id489357827
octolytics-dimension-repository_nwoopen-feature/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id489357827
octolytics-dimension-repository_network_root_nwoopen-feature/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3eeb74f55ccd8a31bdaec6839577c592bbf7844c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/open-feature/python-sdk/issues/96#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopen-feature%2Fpython-sdk%2Fissues%2F96
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopen-feature%2Fpython-sdk%2Fissues%2F96
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=open-feature%2Fpython-sdk
Reloadhttps://github.com/open-feature/python-sdk/issues/96
Reloadhttps://github.com/open-feature/python-sdk/issues/96
Reloadhttps://github.com/open-feature/python-sdk/issues/96
Please reload this pagehttps://github.com/open-feature/python-sdk/issues/96
open-feature https://github.com/open-feature
python-sdkhttps://github.com/open-feature/python-sdk
Notifications https://github.com/login?return_to=%2Fopen-feature%2Fpython-sdk
Fork 43 https://github.com/login?return_to=%2Fopen-feature%2Fpython-sdk
Star 106 https://github.com/login?return_to=%2Fopen-feature%2Fpython-sdk
Code https://github.com/open-feature/python-sdk
Issues 8 https://github.com/open-feature/python-sdk/issues
Pull requests 7 https://github.com/open-feature/python-sdk/pulls
Discussions https://github.com/open-feature/python-sdk/discussions
Actions https://github.com/open-feature/python-sdk/actions
Projects https://github.com/open-feature/python-sdk/projects
Security and quality 0 https://github.com/open-feature/python-sdk/security
Insights https://github.com/open-feature/python-sdk/pulse
Code https://github.com/open-feature/python-sdk
Issues https://github.com/open-feature/python-sdk/issues
Pull requests https://github.com/open-feature/python-sdk/pulls
Discussions https://github.com/open-feature/python-sdk/discussions
Actions https://github.com/open-feature/python-sdk/actions
Projects https://github.com/open-feature/python-sdk/projects
Security and quality https://github.com/open-feature/python-sdk/security
Insights https://github.com/open-feature/python-sdk/pulse
Review thread safety of client/API/Evaluation contexthttps://github.com/open-feature/python-sdk/issues/96#top
1.0-releaseRequired for a 1.0 releasehttps://github.com/open-feature/python-sdk/issues?q=state%3Aopen%20label%3A%221.0-release%22
1.0 Releasehttps://github.com/open-feature/python-sdk/milestone/2
https://github.com/toddbaert
toddbaerthttps://github.com/toddbaert
on Apr 18, 2023https://github.com/open-feature/python-sdk/issues/96#issue-1673147756
herehttps://github.com/open-feature/java-sdk/issues/64
1.0-releaseRequired for a 1.0 releasehttps://github.com/open-feature/python-sdk/issues?q=state%3Aopen%20label%3A%221.0-release%22
1.0 ReleaseNo due datehttps://github.com/open-feature/python-sdk/milestone/2
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.