Skip to content
12 changes: 12 additions & 0 deletions ldclient/impl/datasystem/fdv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ def is_monitoring_enabled(self) -> bool:

return monitoring_enabled()

def close(self):
"""
Close the wrapper and stop the repeating task poller if it's running.
Also forwards the close call to the underlying store if it has a close method.
"""
with self.__lock.write():
if self.__poller is not None:
self.__poller.stop()
self.__poller = None
if hasattr(self.store, "close"):
Comment thread
jsonbailey marked this conversation as resolved.
Outdated
self.store.close()
Comment thread
jsonbailey marked this conversation as resolved.
Outdated
Comment thread
jsonbailey marked this conversation as resolved.
Outdated


class FDv2(DataSystem):
"""
Expand Down
22 changes: 22 additions & 0 deletions ldclient/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,28 @@ def initialized(self) -> bool:
# :return: true if the underlying data store is reachable
# """

# WARN: This isn't a required method on a FeatureStore. The SDK will
# check if the provided store responds to this method, and if it does,
# will call it during shutdown to release any resources (such as database
# connections or connection pools) that the store may be using.
#
# @abstractmethod
# def close(self):
# """
# Releases any resources used by the data store implementation.
#
# This method will be called by the SDK during shutdown to ensure proper
# cleanup of resources such as database connections, connection pools,
# network sockets, or other resources that should be explicitly released.
#
# Implementations should be idempotent - calling close() multiple times
# should be safe and have no additional effect after the first call.
#
# This is particularly important for persistent data stores that maintain
# connection pools or other long-lived resources that should be properly
# cleaned up when the SDK is shut down.
# """


class FeatureStoreCore:
"""
Expand Down