11import logging
2+ import time
23
34from typing import Any , Optional , Union , List
45
910from openfeature .provider .metadata import Metadata
1011from openfeature .evaluation_context import EvaluationContext
1112from openfeature .flag_evaluation import FlagResolutionDetails , Reason
12- from openfeature .exception import ErrorCode , InvalidContextError , TypeMismatchError
13+ from openfeature .exception import ErrorCode , InvalidContextError , TypeMismatchError , GeneralError
1314from openfeature .hook import Hook
1415
1516logger = logging .getLogger (__name__ )
@@ -26,11 +27,27 @@ def __init__(self, devcycle_client: AbstractDevCycleClient):
2627 self .client = devcycle_client
2728 self .meta_data = Metadata (name = f"DevCycle { self .client .get_sdk_platform ()} " )
2829
30+ def initialize (self , evaluation_context : EvaluationContext ) -> None :
31+ timeout = 2
32+ start_time = time .time ()
33+
34+ # Wait for the client to be initialized or timeout
35+ while not self .client .is_initialized ():
36+ if time .time () - start_time > timeout :
37+ raise GeneralError (f"DevCycleProvider initialization timed out after { timeout } seconds" )
38+ time .sleep (0.1 ) # Sleep briefly to avoid busy waiting
39+
40+ if self .client .is_initialized ():
41+ logger .debug ("DevCycleProvider initialized successfully" )
42+
43+ def shutdown (self ) -> None :
44+ self .client .close ()
45+
2946 def get_metadata (self ) -> Metadata :
3047 return self .meta_data
3148
3249 def get_provider_hooks (self ) -> List [Hook ]:
33- return []
50+ return []
3451
3552 def _resolve (
3653 self ,
0 commit comments