Skip to content

feat: Add a start wait timeout for initialization - #59

Merged
kinyoklion merged 6 commits into
mainfrom
devin/1787767005-python-start-wait
Aug 31, 2026
Merged

feat: Add a start wait timeout for initialization#59
kinyoklion merged 6 commits into
mainfrom
devin/1787767005-python-start-wait

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Aug 26, 2026

Copy link
Copy Markdown
Member

Adds a start_wait parameter to LaunchDarklyProvider, defaulting to the LaunchDarkly SDK's five seconds.

Closes #55.

  • The value is passed to LDClient(config, start_wait) and bounds the whole of initialization once: with a positive value initialize reports the outcome the constructor already waited for rather than waiting again, so a five second start wait cannot become a ten second wait for set_provider_and_wait.
  • Initialization fails when the client did not become ready in time; the provider keeps reporting status afterward, so a later connection still makes it ready.
  • Zero does not block the constructor at all, and initialize then waits without a deadline for the data source to become valid or to fail permanently.
  • Flips the README feature matrix's Initialization row to supported, since this is the change that makes it true.
Implementation details
# With a start wait the client constructor has already waited, so the outcome is whatever it is now.
if self.__start_wait <= 0:
    ready_event.wait()

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

#55, and the matching Java change in openfeature-java-server#61. Related spec change: sdk-specs#257.

Describe the solution you've provided

main has since merged #56, #57 and #58; those are merged into this branch, so start_wait composes with the wrapper information now passed to LDClient, and a failed initialization raises ProviderNotReadyError rather than a fatal error.

Describe alternatives you've considered

Waiting on the ready event for start_wait seconds inside initialize as well: that doubled the effective wait, since the client constructor had already waited the same amount.

Additional context

Testing: make test (84 passed) and make lint. Tests cover the default matching the SDK default and initialization failing without waiting a second time; the timing assertion fails rather than hanging CI if the double wait comes back.

Link to Devin session: https://app.devin.ai/sessions/38a6eaf69fcf41109e136a1d0fe5e899
Open in Devin Desktop: https://app.devin.ai/desktop/session/38a6eaf69fcf41109e136a1d0fe5e899?variant=devin
Requested by: @kinyoklion


Note

Overview
Adds an optional start_wait argument to LaunchDarklyProvider (default 5 seconds, aligned with LDClient) so initialization can be bounded instead of waiting indefinitely.

Positive start_wait: the constructor blocks up to that limit while the client connects; initialize does not wait again on the ready event, so total wait time is not doubled (e.g. for set_provider_and_wait). If the client is not ready in time, initialize raises ProviderNotReadyError.

start_wait of 0: the constructor does not block; initialize waits without a deadline until the data source becomes valid or fails permanently (previous behavior).

README marks Initialization as fully supported and documents start_wait. Tests cover the default passed to LDClient and that a positive start_wait does not add a second long wait in initialize (via NeverReadyDataSource).

Reviewed by Cursor Bugbot for commit 69390f7. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the devin-pr Pull request created by Devin AI label Aug 26, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

Comment thread ld_openfeature/provider.py Outdated
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion
kinyoklion marked this pull request as ready for review August 28, 2026 21:52
@kinyoklion
kinyoklion requested a review from a team as a code owner August 28, 2026 21:52
@kinyoklion
kinyoklion marked this pull request as draft August 28, 2026 21:52
devin-ai-integration Bot and others added 4 commits August 28, 2026 21:58
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion
kinyoklion marked this pull request as ready for review August 31, 2026 21:01
@kinyoklion
kinyoklion merged commit c8708fd into main Aug 31, 2026
14 checks passed
@kinyoklion
kinyoklion deleted the devin/1787767005-python-start-wait branch August 31, 2026 21:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 69390f7. Configure here.

ready_event.wait()
# With a start wait the client constructor has already waited, so the outcome is whatever it is now.
if self.__start_wait <= 0:
ready_event.wait()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Timeout drops later ready events

Medium Severity

When start_wait expires, initialize raises ProviderNotReadyError before attaching the data-source and flag listeners. A later LaunchDarkly connection never emits PROVIDER_READY, so OpenFeature stays in ERROR and configuration-change events are also dropped.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 69390f7. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is correct, and it contradicts a bullet in the description above (now fixed): the raise happens before the status and flag-change listeners are attached, so a provider whose start wait lapses stays silent — no PROVIDER_READY when the connection later succeeds, and no configuration-changed events either. It isn't new to this PR (the same was true of the pre-existing is_initialized() failure path), but a start wait makes it reachable from mere slowness rather than only from a permanent failure.

Not changing it here, since it's the same open question as on openfeature-java-server#61: whether a lapsed start wait is terminal for the provider or just a failed initialization it can recover from. Attaching the listeners before the raise is the fix if it's the latter, and it should be decided the same way in both languages.

kinyoklion pushed a commit that referenced this pull request Aug 31, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](0.7.0...0.8.0)
(2026-08-31)


### Features

* Add a start wait timeout for initialization
([#59](#59))
([c8708fd](c8708fd))

---
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]
> **Overview**
> **Release 0.8.0** — mechanical version bump from **0.7.0** across the
release manifest, `pyproject.toml`, `ld_openfeature/version.py`, and
Sphinx `docs/conf.py`, plus a new **CHANGELOG** section dated
2026-08-31.
> 
> The changelog records one user-facing item for this tag:
**configurable start wait timeout for provider initialization** ([#59]),
which was already landed on `main` and is not part of this diff.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7537919. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

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

Labels

devin-pr Pull request created by Devin AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider initialization can block indefinitely

2 participants