If you want to get all results at once, you can use asyncio.gather: https://docs.python.org/dev/library/asyncio-task.html#asyncio.gather
By the way, we should write examples for asyncio task functions. It's not obvious how to use them. Victor 2015-09-01 18:16 GMT+02:00 Ons <[email protected]>: > Hi Victor, > > Thank you for the response. > > In fact what i want to do is to run tasks in parallel and return the result > and not a future. > > From what i understood, with asyncio event loop, tasks are executed in an > asynchronous manner in the same thread. But if i need to execute tasks in > parallel, do i have other options other than running an event loop in a > separate thread for each task ? > > > On Monday, August 31, 2015 at 2:05:33 PM UTC+1, Ons wrote: >> >> Hello, >> >> I am using asyncio event loop in my project and i need to make non >> blocking calls of lets say a coroutine called async. >> >> @asyncio.coroutine >> def async(attr1, attr2): >> //my coroutine code here >> >> loop = asyncio.get_event_loop() >> result = yield from loop.run_in_executor(None, async('attr1', 'attr2')) >> return result >> >> I am getting the following error : TypeError: 'Task' object is not >> callable. >> >> How can i run a coroutine in a non blocking mode with asyncio ? >> >> Thanks.
