Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
cblmemo committed May 8, 2024
1 parent 484d08b commit 3f10b52
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sky/serve/load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def _sync_with_controller(self):
ready_replica_urls = response.json().get(
'ready_replica_urls')
except requests.RequestException as e:
logger.error(f'An error occurred when syncing with the controller: {e}')
logger.error('An error occurred when syncing with '
f'the controller: {e}')
else:
logger.info(f'Available Replica URLs: {ready_replica_urls}')
with self._client_pool_lock:
Expand All @@ -91,10 +92,12 @@ def _sync_with_controller(self):
self._client_pool[replica_url] = (
httpx.AsyncClient(
base_url=f'http://{replica_url}'))
urls_to_close = set(self._client_pool.keys()) - set(ready_replica_urls)
urls_to_close = set(
self._client_pool.keys()) - set(ready_replica_urls)
client_to_close = []
for replica_url in urls_to_close:
client_to_close.append(self._client_pool.pop(replica_url))
client_to_close.append(
self._client_pool.pop(replica_url))
for client in client_to_close:
asyncio.run(client.aclose())

Expand Down Expand Up @@ -165,8 +168,8 @@ async def _proxy_with_retries(
ready_replica_url, request)
if not isinstance(response_or_exception, Exception):
return response_or_exception
# When the user aborts the request during streaming, the request will be disconnected.
# We do not need to retry for this case.
# When the user aborts the request during streaming, the request
# will be disconnected. We do not need to retry for this case.
if await request.is_disconnected():
# 499 means a client terminates the connection
# before the server is able to respond.
Expand Down

0 comments on commit 3f10b52

Please sign in to comment.