Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105704 > unrolled thread

Re: Adding run_in_executor task to already existing loop.

Started byRay Cote <rgacote@appropriatesolutions.com>
First post2016-03-25 17:06 -0400
Last post2016-03-25 17:06 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Adding run_in_executor task to already existing loop. Ray Cote <rgacote@appropriatesolutions.com> - 2016-03-25 17:06 -0400

#105704 — Re: Adding run_in_executor task to already existing loop.

FromRay Cote <rgacote@appropriatesolutions.com>
Date2016-03-25 17:06 -0400
SubjectRe: Adding run_in_executor task to already existing loop.
Message-ID<mailman.10.1458939998.28225.python-list@python.org>
On Fri, Mar 25, 2016 at 5:00 PM, Zachary Ware <zachary.ware+pylist@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@AppropriateSolutions.com skype:
ray.cote

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web