Skip to content

Comments

fix: Add context manager for clearer, safer locks#396

Merged
jsonbailey merged 6 commits intomainfrom
jb/sdk-1710/lock-context-manager
Jan 6, 2026
Merged

fix: Add context manager for clearer, safer locks#396
jsonbailey merged 6 commits intomainfrom
jb/sdk-1710/lock-context-manager

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Jan 6, 2026

Note

Introduces context-managed read/write locking and refactors SDK code to use it for clearer, safer concurrency.

  • Adds ReadWriteLock.read()/write() context managers and updates all locking sites to with blocks (replacing manual lock()/unlock() and rlock()/runlock()) across ldclient/__init__.py, client.py, feature_store.py, data source/store status providers, FDv2 datasystem (wrapper, store, lifecycle), listeners, flag tracker, and integrations/test_data*
  • Minor internal cleanups while preserving behavior (e.g., poller start/stop guarded by write locks, listener lists copied under read locks)

Written by Cursor Bugbot for commit cf0f77a. This will update automatically on new commits. Configure here.

@jsonbailey jsonbailey marked this pull request as ready for review January 6, 2026 16:23
@jsonbailey jsonbailey requested a review from a team as a code owner January 6, 2026 16:23
@jsonbailey jsonbailey changed the title fix: Add context manager to rw lock fix: Add context manager for clearer/safer locks Jan 6, 2026
@jsonbailey jsonbailey changed the title fix: Add context manager for clearer/safer locks fix: Add context manager for clearer, safer locks Jan 6, 2026
global __lock
try:
__lock.lock()
c = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thing of beauty.

@jsonbailey jsonbailey merged commit beca0fa into main Jan 6, 2026
15 checks passed
@jsonbailey jsonbailey deleted the jb/sdk-1710/lock-context-manager branch January 6, 2026 21:36
jsonbailey added a commit that referenced this pull request Feb 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[9.15.0](9.14.1...9.15.0)
(2026-02-10)


### Features

* Drop support for python 3.9
([#393](#393))
([5b761bd](5b761bd))
* Update ChangeSet to always require a Selector
([#405](#405))
([5dc4f81](5dc4f81))


### Bug Fixes

* Add context manager for clearer, safer locks
([#396](#396))
([beca0fa](beca0fa))
* Address potential race condition in FeatureStore update_availability
([#391](#391))
([31cf487](31cf487))
* Allow modifying fdv2 data source options independent of main config
([#403](#403))
([d78079e](d78079e))
* Mark copy_with_new_sdk_key method as deprecated
([#353](#353))
([e471ccc](e471ccc))
* Prevent immediate polling on recoverable error
([#399](#399))
([da565a2](da565a2))
* Redis store is considered initialized when `$inited` key is written
([e99a27d](e99a27d))
* Stop FeatureStoreClientWrapper poller on close
([#397](#397))
([468afdf](468afdf))
* Update DataSystemConfig to accept list of synchronizers
([#404](#404))
([c73ad14](c73ad14))
* Update reason documentation with inExperiment value
([#401](#401))
([cbfc3dd](cbfc3dd))
* Update Redis to write missing `$inited` key
([e99a27d](e99a27d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Release-only changes (version strings and documentation) with no
functional code modifications in this diff.
> 
> **Overview**
> Bumps the SDK release from `9.14.1` to `9.15.0` across version sources
(`pyproject.toml`, `ldclient/version.py`, release-please manifest) and
updates `PROVENANCE.md` to reference the new version.
> 
> Updates `CHANGELOG.md` with the `9.15.0` release notes, including FDv2
EAP breaking API adjustments (e.g., `ChangeSetBuilder.finish()` now
requires a `Selector`, and `DataSystemConfig.synchronizers` supports
multiple synchronizers), Python 3.9 support drop, and a set of bug-fix
entries.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
71a9224. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jsonbailey <jbailey@launchdarkly.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants