GithubHelp home page GithubHelp logo

Comments (5)

obendidi avatar obendidi commented on June 18, 2024

Hey @mjkanji,

Thanks for opening the issue, I'll have a more detailed look later when I have the time :)

First question, does UPath support async operations ?

It makes sense for it not to work with the async client, since we wrap the pathlib.Path object with an anyio.Path wrapper to add async I/O ops:

async def aget(self, request: httpx.Request) -> tp.Optional[httpx.Response]:
filepath = anyio.Path(
get_cache_filepath(self.cache_dir, request, extra=self._extra)
)
async with self.async_lock.reader:
if await filepath.is_file():
try:
cached = await filepath.read_bytes()
return self.serializer.loads(request=request, cached=cached)
except Exception:
return None
return None

It works with the sync client since we use the user provided path directly.

from httpx-cache.

obendidi avatar obendidi commented on June 18, 2024

A new version has been released with async support for UPath, let me know if it works out to close the issue :)

https://obendidi.github.io/httpx-cache/guide/#fsspecuniversal_pathlib-integration

from httpx-cache.

mjkanji avatar mjkanji commented on June 18, 2024

A new version has been released with async support for UPath, let me know if it works out to close the issue :)

It is working, indeed! Thank you for the quick fix!

A quick clarification: does this also work for the (Async)CacheControlTransport or just the clients?

from httpx-cache.

obendidi avatar obendidi commented on June 18, 2024

should work for everything, the clients use the CacheControlTransport inside

from httpx-cache.

mjkanji avatar mjkanji commented on June 18, 2024

Awesome, thanks!

from httpx-cache.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.