Tinche / aiofiles

File support for asyncio
Apache License 2.0
2.76k stars 150 forks source link

No implementation of cwd or abspath? #181

Closed GodefroyClair closed 4 months ago

GodefroyClair commented 4 months ago

If I'm not mistaken, neitherget_cwd nor abspath (which is juste normpath(join(os.getcwd(), path)) according to the doc in the os package) are implemented in aiofiles. It seems like important function that do IO operations if I'm not mistaken. Is there a fundamental reason why it is not implemented in aiofiles? Thanks!

Tinche commented 4 months ago

There's no fundamental reason. Are get_cwd and abspath blocking in the first place?

Probably no one asked for it or contributed it. If you feel like adding it (should be fairly simple) feel free to send a PR!

GodefroyClair commented 4 months ago

Well, abspath calls getcwd and, on Linux,getcwdcalls the POSIX functon getcwd. This function is a system call. Exactly what implementation is behind that is beyond my knowledge. How would you evaluate how "blocking" a function is ? https://hg.python.org/cpython/file/tip/Modules/posixmodule.c https://man7.org/linux/man-pages/man3/getcwd.3.html

...and yes, if needed, I would be very happy to help and send a PR...