Skip to content

Commit

Permalink
feat: added client.wait_for_start() (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare authored Oct 17, 2024
1 parent 16ff14f commit b693873
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aw_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,20 @@ def disconnect(self):
# Throw away old thread object, create new one since same thread cannot be started twice
self.request_queue = RequestQueue(self)

def wait_for_start(self, timeout: int = 10) -> None:
"""Wait for the server to start by trying to get the server info."""
start_time = datetime.now()
sleep_time = 0.1
while (datetime.now() - start_time).seconds < timeout:
try:
self.get_info()
break
except req.exceptions.ConnectionError:
sleep(sleep_time)
sleep_time *= 2
else:
raise Exception("Server did not start in time")


QueuedRequest = namedtuple("QueuedRequest", ["endpoint", "data"])
Bucket = namedtuple("Bucket", ["id", "type"])
Expand Down

0 comments on commit b693873

Please sign in to comment.