Skip to content

Commit

Permalink
Make the delete method asynchronous in AsyncFirecrest (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekouts authored Apr 3, 2024
1 parent 3a197ca commit c95cd47
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions firecrest/AsyncClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ async def _put_request(
@_retry_requests # type: ignore
async def _delete_request(
self, endpoint, additional_headers=None, data=None
) -> requests.Response:
) -> httpx.Response:
microservice = endpoint.split("/")[1]
url = f"{self._firecrest_url}{endpoint}"
async with self._locks[microservice]:
Expand All @@ -369,10 +369,15 @@ async def _delete_request(
headers.update(additional_headers)

logger.info(f"Making DELETE request to {endpoint}")
# TODO: httpx doesn't support data in delete so we will have to
# keep using the `requests` package for this
resp = requests.delete(
url=url, headers=headers, data=data, timeout=self.timeout
# httpx doesn't support data in the `delete` method so we will have to
# use the generic `request` method
# https://www.python-httpx.org/compatibility/#request-body-on-http-methods
resp = await self._session.request(
method="DELETE",
url=url,
headers=headers,
data=data,
timeout=self.timeout,
)
self._next_request_ts[microservice] = (
time.time() + self.time_between_calls[microservice]
Expand Down

0 comments on commit c95cd47

Please sign in to comment.