Commit c8708fd
feat: Add a start wait timeout for initialization (#59)
Adds a `start_wait` parameter to `LaunchDarklyProvider`, defaulting to
the LaunchDarkly SDK's five seconds.
Closes
[#55](#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.
<details>
<summary>Implementation details</summary>
```python
# 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**
- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions
**Related issues**
[#55](#55),
and the matching Java change in
[openfeature-java-server#61](launchdarkly/openfeature-java-server#61).
Related spec change:
[sdk-specs#257](launchdarkly/sdk-specs#257).
**Describe the solution you've provided**
`main` has since merged
[#56](#56),
[#57](#57)
and
[#58](#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.
</details>
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
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> <sup>[Cursor Bugbot](https://cursor.com/bugbot) is generating a
summary for commit 69390f7. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 20ba8c1 commit c8708fd
4 files changed
Lines changed: 61 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
| |||
84 | 96 | | |
85 | 97 | | |
86 | 98 | | |
87 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
88 | 102 | | |
89 | 103 | | |
90 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
53 | 76 | | |
54 | 77 | | |
55 | 78 | | |
| |||
0 commit comments