Skip to content

Commit

Permalink
Use daemon argument to ensure that polling manager is killed (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Jul 7, 2023
1 parent 13d5a8d commit 5ed3c6c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions flagsmith/flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(
EnvironmentDataPollingManager(
main=self,
refresh_interval_seconds=environment_refresh_interval_seconds,
daemon=True, # noqa
)
)
self.environment_data_polling_manager_thread.start()
Expand Down
8 changes: 6 additions & 2 deletions flagsmith/polling_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

class EnvironmentDataPollingManager(threading.Thread):
def __init__(
self, main: "Flagsmith", refresh_interval_seconds: typing.Union[int, float] = 10
self,
*args,
main: "Flagsmith",
refresh_interval_seconds: typing.Union[int, float] = 10,
**kwargs
):
super(EnvironmentDataPollingManager, self).__init__()
super(EnvironmentDataPollingManager, self).__init__(*args, **kwargs)
self._stop_event = threading.Event()
self.main = main
self.refresh_interval_seconds = refresh_interval_seconds
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def local_eval_flagsmith(server_api_key, environment_json, mocker):

yield flagsmith

flagsmith.__del__()
del flagsmith


@pytest.fixture()
Expand Down

0 comments on commit 5ed3c6c

Please sign in to comment.