Skip to content

Commit e81abd0

Browse files
committed
fix: shutdown all providers on api.shutdown
Signed-off-by: Federico Bond <[email protected]>
1 parent 36c9e3f commit e81abd0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: openfeature/api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ def get_hooks() -> typing.List[Hook]:
9696

9797

9898
def shutdown() -> None:
99-
_provider.shutdown()
99+
for provider in {_provider, *_providers.values()}:
100+
provider.shutdown()

Diff for: tests/test_api.py

+17
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,20 @@ def test_should_not_shutdown_provider_bound_to_another_domain():
193193
set_provider(other_provider, "foo")
194194

195195
provider.shutdown.assert_not_called()
196+
197+
198+
def test_shutdown_should_shutdown_every_registered_provider_once():
199+
# Given
200+
provider_1 = MagicMock(spec=FeatureProvider)
201+
provider_2 = MagicMock(spec=FeatureProvider)
202+
set_provider(provider_1)
203+
set_provider(provider_1, "foo")
204+
set_provider(provider_2, "bar")
205+
set_provider(provider_2, "baz")
206+
207+
# When
208+
shutdown()
209+
210+
# Then
211+
provider_1.shutdown.assert_called_once()
212+
provider_2.shutdown.assert_called_once()

0 commit comments

Comments
 (0)