Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
fix not working with python3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
obendidi committed Sep 13, 2023
1 parent e4bb95a commit 8f51c01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions httpx_cache/cache/file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import typing as tp
from pathlib import Path
from functools import partial

from anyio import to_thread
from fasteners import ReaderWriterLock as RWLock
Expand Down Expand Up @@ -102,7 +103,11 @@ async def aset(
async with self.async_lock.writer:
to_cache = self.serializer.dumps(response=response, content=content)
try:
await to_thread.run_sync(filepath.write_bytes, to_cache)
await to_thread.run_sync(
filepath.write_bytes,
to_cache,
cancellable=True,
)
except Exception:
return None

Expand All @@ -115,4 +120,5 @@ def delete(self, request: httpx.Request) -> None:
async def adelete(self, request: httpx.Request) -> None:
filepath = get_cache_filepath(self.cache_dir, request, extra=self._extra)
async with self.async_lock.writer:
await to_thread.run_sync(filepath.unlink, True)
_func = partial(filepath.unlink, missing_ok=True)
await to_thread.run_sync(_func, cancellable=True)

0 comments on commit 8f51c01

Please sign in to comment.