Python version of asyncio `os.chmod`

I have Python3 code running inside an asyncio event asyncio .

I want to use the os.chmod(...) functionality, but ideally I would like a non-blocking version of this, so I can use await os.chmod(...) and not make the system call lock.

I do not believe that there are libraries that provide this functionality, at least from what I see.

How can I implement non-blocking os.chmod(...) from scratch? Better yet, is there an existing solution?

+7
python chmod python-asyncio
source share
1 answer

UNIX systems do not implement the asynchronous API for syscall chmod . Thus, it is best to execute it in a thread pool:

 await loop.run_in_executor(None, os.chmod, fname, mode) 
+6
source share

All Articles