Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/superannotate/lib/infrastructure/services/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ async def _sync_large_annotation(self, team_id, project_id, item_id):
async with AIOHttpSession(
connector=aiohttp.TCPConnector(ssl=False),
headers=self.client.default_headers,
raise_for_status=True,
) as session:
_response = await session.request("post", sync_url, params=sync_params)
_response.raise_for_status()
sync_params.pop("current_source")
sync_params.pop("desired_source")

Expand Down Expand Up @@ -123,9 +123,9 @@ async def get_big_annotation(
async with AIOHttpSession(
connector=aiohttp.TCPConnector(ssl=False),
headers=self.client.default_headers,
raise_for_status=True,
) as session:
start_response = await session.request("post", url, params=query_params)
start_response.raise_for_status()
large_annotation = await start_response.json()

reporter.update_progress()
Expand Down Expand Up @@ -206,9 +206,9 @@ async def download_big_annotation(
async with AIOHttpSession(
connector=aiohttp.TCPConnector(ssl=False),
headers=self.client.default_headers,
raise_for_status=True,
) as session:
start_response = await session.request("post", url, params=query_params)
start_response.raise_for_status()
res = await start_response.json()
Path(download_path).mkdir(exist_ok=True, parents=True)

Expand Down
9 changes: 5 additions & 4 deletions src/superannotate/lib/infrastructure/services/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ async def request(self, *args, **kwargs) -> aiohttp.ClientResponse:
response = await super()._request(*args, **kwargs)
if attempts <= 1 or response.status not in self.RETRY_STATUS_CODES:
return response
if isinstance(kwargs["data"], aiohttp.FormData):
raise RuntimeError(await response.text())
except (aiohttp.ClientError, RuntimeError) as e:
if attempts <= 1:
raise
if isinstance(e, RuntimeError):
data = kwargs["data"]
if isinstance(data, aiohttp.FormData):
kwargs["data"] = self._copy_form_data(data)
data = kwargs["data"]
if isinstance(data, aiohttp.FormData):
kwargs["data"] = self._copy_form_data(data)
attempts -= 1
await asyncio.sleep(delay)