Make my own function as asyncio function in python
<p>I would like to use asyncio module in Python to achieve doing request tasks in parallel because my current request tasks works in sequence, which means it is blocking.</p>

<p>I have read the documents of asyncio module in Python, and I have wrote some simple code as follows, however it doesn't work as I thought.</p>

<pre><code>import asyncio
class Demo(object):

    def demo(self):
        loop = asyncio.get_event_loop()
        tasks = [task1.verison(), task2.verison()]
        result = loop.run_until_complete(asyncio.wait(tasks))
        loop.close()
        print(result)

class Task():
   @asyncio.coroutine
   def version(self):
       print('before')
       result = yield from differenttask.GetVersion() 
       # result = yield from asyncio.sleep(1)
       print('after')
</code></pre>

<p>I found out that all the example they give use asyncio function to make the non-blocking works, how to make own function works as a asyncio?</p>

<p>What I want to achieve is that for a task it will execute the request and doesn't wait the response then it switch to next task. When I tried this: I get <code>RuntimeError: Task got bad yield: 'hostname'</code>, which <em>hostname</em> is one item in my expected result.</p>

<p>so as @AndrewSvetlov said, differentask.GetVersion() is a regular synchronous function. I have tried the second method suggested in <a href="https://stackoverflow.com/questions/30172821/python-asyncio-task-got-bad-yield?rq=1">similar post</a>, --- the one <code>Keep your synchronous implementation of searching...blabla</code></p>

<pre><code>@asyncio.coroutine
def version(self):
    return (yield from asyncio.get_event_loop().run_in_executor(None, self._proxy.GetVersion()))
</code></pre>

<p>And it still doesn't work, Now the error is 
<code>Task exception was never retrieved
future: &lt;Task finished coro=&lt;Task.version() done, defined at /root/syi.py:34&gt; exception=TypeError("'dict' object is not callable",)&gt;</code></p>

<p>I'm not sure if I understand if it right, please advice.</p>