Skip to content

Commit 30db6a5

Browse files
committed
Remote services gain a method for waiting for a connection to come up
It is useful when a stand-alone script needs to talk to a remote service, because service.connect() returns while the connection attempt is being done in the background.
1 parent 8934ad2 commit 30db6a5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cms/io/rpc.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ def connected(self) -> bool:
118118
"""
119119
return self._connection_event.is_set()
120120

121+
def wait_for_connection(self, timeout: float | None = None) -> bool:
122+
"""Wait for a limited time until the connection comes up.
123+
124+
timeout: maximum waiting time in seconds.
125+
126+
result: the status of the connection.
127+
128+
"""
129+
return self._connection_event.wait(timeout)
130+
121131
# TODO: the types here are not precise
122132
def add_on_connect_handler(self, handler: Callable[[object], Any]):
123133
"""Register a callback for connection establishment.

0 commit comments

Comments
 (0)