Open andrewkruse opened 1 week ago
I wouldn't override aiofiles.threadpool.sync_open
with smart_open, other modules in your codebase maybe depend on aiofiles (or will in the future) and that might mess them up. It's a very global change.
What aiofiles does is just run functions in a thread pool. Maybe you can run the smart_open stuff in a threadpool yourself?
I am currently using fastapi to return a streaming response from results in google cloud storage. So, with fastapi, I have a few things that I use that make me want to use the
async def
options (asyncpg, aiohttp). But, if I do that my understanding is that as soon as I do blocking io in that same thread I'm going to get a stalled event loop.As an option, I'm wondering if I can use this library and tack smart_open inside and expect it to continue working and not stall my event loop? Or perhaps there's a better/alternative way to patch smart open into this library in place of the regular open call?
Here's what I'm executing: