Skip to content

Commit 37a92b5

Browse files
remote: make start_session() args more explicit
During the move to gRPC, start_session()'s arguments changed. Since this is one of the functions used from outside of labgrid, add typing hints and force the kwargs to be passed with names. This should make users aware of the changes, so their code can be adapted. Signed-off-by: Bastian Krause <[email protected]>
1 parent 545d240 commit 37a92b5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

labgrid/remote/client.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from collections import defaultdict, OrderedDict
2424
from datetime import datetime
2525
from pprint import pformat
26+
from typing import Any, Dict
2627

2728
import attr
2829
import grpc
@@ -1566,7 +1567,19 @@ def ensure_event_loop(external_loop=None):
15661567
return loop
15671568

15681569

1569-
def start_session(address, extra=None, debug=False, loop=None):
1570+
def start_session(
1571+
address: str, *, extra: Dict[str, Any] = None, debug: bool = False, loop: "asyncio.AbstractEventLoop | None" = None
1572+
):
1573+
"""
1574+
Starts a ClientSession.
1575+
1576+
Args:
1577+
address: coordinator address as HOST[:PORT], PORT defaults to 20408
1578+
extra: additional kwargs for ClientSession
1579+
debug: set debug mode of the event loop
1580+
loop: explicit event loop to use (otherwise a previously stashed loop,
1581+
if retrievable the current thread's loop or a new loop is used)
1582+
"""
15701583
loop = ensure_event_loop(loop)
15711584

15721585
if extra is None:

labgrid/resource/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _start(self):
2222

2323
from ..remote.client import start_session
2424
try:
25-
self.session = start_session(self.url, {'env': self.env})
25+
self.session = start_session(self.url, extra={'env': self.env})
2626
except ConnectionRefusedError as e:
2727
raise ConnectionRefusedError(f"Could not connect to coordinator {self.url}") \
2828
from e

0 commit comments

Comments
 (0)