Uvloop: libuv filesystem async calls

Created on 17 Nov 2015  路  14Comments  路  Source: MagicStack/uvloop

AFAIK, libuv also support async filesystem calls. Can this be implemented in uvloop (or based on uvloop) with nice await with and some pathlib awaitable coroutines? If so, 芦not good禄 executors for filesystem calls can be dropped :clap:

enhancement

Most helpful comment

Yes, once I'm done with adding/testing the basic APIs, we'll experiment with files ;)

All 14 comments

Yes, once I'm done with adding/testing the basic APIs, we'll experiment with files ;)

Great!

For my information, behind the scenes, it uses what on Linux? Threads?

It uses threads on all platforms -- that's the only reliable way.

@1st1 hm, if so, is there any profit of use libuv for file io?

I've no idea. I think it will be a bit faster, since IO threadpool in libuv is implemented in C (compared to pure Python executors in asyncio).

@1st1 sounds right. And I answer my question: this will be the only solution (with nice syntax of course), since AFAIK there is no async filesystem library in python except aiofiles (but this have no path operations).
Thanks for great project! :+1:

FWIW, the current builtin threadpool just has 4 threads.

@saghul Is that usually enough (I assume getaddrinfo uses the same threadpool)? Would be great to have an API call to change the size, instead of the UV_THREADPOOL_SIZE env var...

So far it has been... unless you use it for long running blocking operations like talking to serial devices. We have plans to improve it, but no real ETA.

@saghul: a filesystem stored on a slow SAN because it's overloaded, could also be considered as a long running blocking operation like serial, or not?

Yep.

@GMLudo That's not a problem atm, since uvloop doesn't have any methods to work with files.

I'll just close this. First async file IO must be implemented in asyncio directly.

Was this page helpful?
0 / 5 - 0 ratings