Skip to content

Commit fb7dbde

Browse files
committed
Fix: I broke it
1 parent cba6d40 commit fb7dbde

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/obelisk/asynchronous/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ async def _get_token(self):
7676

7777
async with httpx.AsyncClient() as client:
7878
response = None
79+
request = None
7980
last_error = None
8081
retry = self.retry_strategy.make()
8182
while not response:
@@ -87,7 +88,6 @@ async def _get_token(self):
8788
headers=headers)
8889

8990
response = request.json()
90-
break
9191
except Exception as e:
9292
last_error = e
9393
self.log.error(e)
@@ -96,10 +96,8 @@ async def _get_token(self):
9696
else:
9797
break
9898

99-
if response is None and last_error is not None:
100-
raise last_error
101-
102-
raise ObeliskError("No response received")
99+
if not response or not request:
100+
raise (last_error if last_error is not None else ObeliskError("No response"))
103101

104102
if request.status_code != 200:
105103
if 'error' in response:
@@ -148,7 +146,7 @@ async def http_post(self, url: str, data: Any = None,
148146
response = None
149147
retry = self.retry_strategy.make()
150148
last_error = None
151-
while not response or await retry.should_retry():
149+
while not response:
152150
if response is not None:
153151
self.log.debug(f"Retrying, last response: {response.status_code}")
154152

@@ -164,7 +162,10 @@ async def http_post(self, url: str, data: Any = None,
164162
except Exception as e:
165163
self.log.error(e)
166164
last_error = e
167-
continue
165+
if await retry.should_retry():
166+
continue
167+
else:
168+
break
168169

169170
if not response and last_error:
170171
raise last_error

0 commit comments

Comments
 (0)