diff --git a/healthchain/clients/ehrclient.py b/healthchain/clients/ehrclient.py index bba59b5..1bd12c4 100644 --- a/healthchain/clients/ehrclient.py +++ b/healthchain/clients/ehrclient.py @@ -99,7 +99,11 @@ def wrapper(self, *args: Any, **kwargs: Any) -> EHRClient: class EHRClient(BaseClient): def __init__( - self, func: Callable[..., Any], workflow: Workflow, strategy: BaseStrategy + self, + func: Callable[..., Any], + workflow: Workflow, + strategy: BaseStrategy, + timeout: Optional[float] = 10.0, ): """ Initializes the EHRClient with a data generator function and optional workflow and use case. @@ -109,7 +113,9 @@ def __init__( func (Callable[..., Any]): A function to generate data for requests. workflow ([Workflow]): The workflow context to apply to the data generator. strategy (BaseStrategy): The strategy object to construct requests based on the generated data. - + timeout(Optional[float], default=10.0) : The maximum time in seconds to wait for a response from the server. + This parameter determines how long the client will wait before considering a request timed out. + A higher timeout value allows for longer-running operations, while a lower value prioritizes faster responses. """ # TODO: Add option to pass in different provider options self.data_generator_func: Callable[..., Any] = func @@ -117,6 +123,7 @@ def __init__( self.strategy: BaseStrategy = strategy self.vendor = None self.request_data: List[CDSRequest] = [] + self.timeout = timeout def set_vendor(self, name) -> None: self.vendor = name @@ -150,7 +157,7 @@ async def send_request(self, url: str) -> List[Dict]: async with httpx.AsyncClient() as client: responses: List[Dict] = [] # TODO: pass timeout as config - timeout = httpx.Timeout(10.0, read=None) + timeout = httpx.Timeout(self.timeout, read=None) for request in self.request_data: try: if self.strategy.api_protocol == ApiProtocol.soap: