|
30 | 30 | from typing import Optional, Dict, List
|
31 | 31 |
|
32 | 32 | import httpx
|
33 |
| -from aiohttp_retry import RetryClient, ExponentialRetry |
| 33 | +from aiohttp_retry import RetryClient, ExponentialRetry, asyncio |
34 | 34 | from google.auth import jwt
|
35 | 35 |
|
36 | 36 | from servicex.models import TransformRequest, TransformStatus
|
@@ -133,11 +133,20 @@ async def get_transform_status(self, request_id: str) -> TransformStatus:
|
133 | 133 | headers = await self._get_authorization()
|
134 | 134 | retry_options = ExponentialRetry(attempts=5, start_timeout=10)
|
135 | 135 | 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