Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105704
| From | Ray Cote <rgacote@appropriatesolutions.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Adding run_in_executor task to already existing loop. |
| Date | 2016-03-25 17:06 -0400 |
| Message-ID | <mailman.10.1458939998.28225.python-list@python.org> (permalink) |
| References | <CAG5tnzpKOXfo4tz4tvF2aBsx0p5awGN4GhYN6wYn3kfY_ZQ0Bg@mail.gmail.com> <CAKJDb-OehiunT53Rqet9OmhigUwoBGVXchnmizz+weKRe0pakQ@mail.gmail.com> |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Adding run_in_executor task to already existing loop. Ray Cote <rgacote@appropriatesolutions.com> - 2016-03-25 17:06 -0400
csiph-web