Adding run_in_executor task to already existing loop.

Ray Cote rgacote at appropriatesolutions.com
Fri Mar 25 17:06:06 EDT 2016


On Fri, Mar 25, 2016 at 5:00 PM, Zachary Ware <zachary.ware+pylist at gmail.com
> wrote:

> I'm assuming you're doing `await process_request()` elsewhere, which
> is what's producing your error: you're trying to start the loop within
> a coroutine running on that loop.  loop.run_in_executor() returns a
> Future just like any other coroutine, so process_request just needs
> this:
>
>    async def process_request():
>        loop = asyncio.get_event_loop()
>        results = await loop.run_in_executor(None, blocking_func, 'hello')
>

Yes, that was precisely the directive I needed. This is now working
perfectly.
Thanks
—Ray



-- 
Raymond Cote, President
voice: +1.603.924.6079 email: rgacote at AppropriateSolutions.com skype:
ray.cote



More information about the Python-list mailing list