aiofiles
aiofiles copied to clipboard
Cancel a pending open() call
I'm using aiofiles to read from a named pipe, which doesn't actually complete until the pipe is opened elsewhere for writing, so the read loop spends most of its time in that state. As far as I can tell, there is no way to cancel the open once it is called and clean up or gracefully exit the application.
The way aiofiles works is by wrapping blocking calls in a function that uses threads. This unfortunately has inherent limitations, for example threads can't be portably and safely cancelled, unlike asyncio tasks. So I'm not sure what to do here.