Skip to content

Commit b4af844

Browse files
committed
Pass through timeout arguments for the client
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 76da703 commit b4af844

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040
# plugins.mkdocstrings.handlers.python.import)
4141
"frequenz-sdk >= 1.0.0-rc1900, < 1.0.0-rc2100",
4242
"frequenz-channels >= 1.6.1, < 2.0.0",
43-
"frequenz-client-dispatch >= 0.10.1, < 0.11.0",
43+
"frequenz-client-dispatch >= 0.10.2, < 0.11.0",
4444
]
4545
dynamic = ["version"]
4646

src/frequenz/dispatch/_dispatcher.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,33 @@ async def run():
198198
```
199199
"""
200200

201+
# pylint: disable-next=too-many-arguments
201202
def __init__(
202203
self,
203204
*,
204205
microgrid_id: int,
205206
server_url: str,
206207
key: str,
208+
call_timeout: timedelta = timedelta(seconds=60),
209+
stream_timeout: timedelta = timedelta(minutes=5),
207210
):
208211
"""Initialize the dispatcher.
209212
210213
Args:
211214
microgrid_id: The microgrid id.
212215
server_url: The URL of the dispatch service.
213216
key: The key to access the service.
217+
call_timeout: The timeout for API calls.
218+
stream_timeout: The timeout for streaming API calls.
214219
"""
215220
super().__init__()
216221

217-
self._client = DispatchApiClient(server_url=server_url, key=key)
222+
self._client = DispatchApiClient(
223+
server_url=server_url,
224+
key=key,
225+
call_timeout=call_timeout,
226+
stream_timeout=stream_timeout,
227+
)
218228
self._bg_service = DispatchScheduler(
219229
microgrid_id,
220230
self._client,

tests/test_managing_actor.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,18 @@ async def test_manage_abstraction(
327327
class MyFakeClient(FakeClient):
328328
"""Fake client for testing."""
329329

330-
def __init__(self, *, server_url: str, key: str):
330+
def __init__(
331+
self,
332+
*,
333+
server_url: str,
334+
key: str,
335+
call_timeout: timedelta,
336+
stream_timeout: timedelta,
337+
) -> None:
331338
assert server_url
332339
assert key
340+
assert call_timeout
341+
assert stream_timeout
333342
super().__init__()
334343

335344
mid = 1

0 commit comments

Comments
 (0)