aiofiles icon indicating copy to clipboard operation
aiofiles copied to clipboard

Cancel a pending open() call

Open DaveCausey opened this issue 2 years ago • 1 comments

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.

DaveCausey avatar Feb 09 '23 22:02 DaveCausey

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.

Tinche avatar Feb 12 '23 18:02 Tinche