Skip to content

Commit 7d3c524

Browse files
committed
Add retries for get_transform_status function
1 parent e681796 commit 7d3c524

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

servicex/servicex_adapter.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from typing import Optional, Dict, List
3131

3232
import httpx
33-
from aiohttp_retry import RetryClient, ExponentialRetry
33+
from aiohttp_retry import RetryClient, ExponentialRetry, asyncio
3434
from google.auth import jwt
3535

3636
from servicex.models import TransformRequest, TransformStatus
@@ -133,11 +133,20 @@ async def get_transform_status(self, request_id: str) -> TransformStatus:
133133
headers = await self._get_authorization()
134134
retry_options = ExponentialRetry(attempts=5, start_timeout=10)
135135
async with RetryClient(retry_options=retry_options) as client:
136-
async with client.get(url=f"{self.url}/servicex/transformation/{request_id}",
137-
headers=headers) as r:
138-
if r.status == 401:
139-
raise AuthorizationError(f"Not authorized to access serviceX at {self.url}")
140-
if r.status == 404:
141-
raise ValueError(f"Transform ID {request_id} not found")
142-
o = await r.json()
143-
return TransformStatus(**o)
136+
retries = 5
137+
for retry in range(retries):
138+
try:
139+
async with client.get(url=f"{self.url}/servicex/transformation/{request_id}",
140+
headers=headers) as r:
141+
if r.status == 401:
142+
raise AuthorizationError("Not authorized to access serviceX"
143+
f"at {self.url}")
144+
if r.status == 404:
145+
raise ValueError(f"Transform ID {request_id} not found")
146+
o = await r.json()
147+
return TransformStatus(**o)
148+
except RuntimeError as e:
149+
if retry == retries:
150+
raise RuntimeError("ServiceX WebAPI Error"
151+
f"while getting transform status: {e}")
152+
await asyncio.sleep(3)

0 commit comments

Comments
 (0)