title: How to call a async function contained in a class?
body: <p>Based on <a href="https://stackoverflow.com/a/37370823/1709738">this answer</a> I want to build an async websoket client in a class which would be imported from another file:</p>
  
  <pre><code>#!/usr/bin/env python3
  
  import sys, json
  import asyncio
  from websockets import connect
  
  class EchoWebsocket:
      def __await__(self):
          # see: https://stackoverflow.com/a/33420721/1113207
          return self._async_init().__await__()
  
      async def _async_init(self):
          self._conn = connect('wss://ws.binaryws.com/websockets/v3')
          self.websocket = await self._conn.__aenter__()
          return self
  
      async def close(self):
          await self._conn.__aexit__(*sys.exc_info())
  
      async def send(self, message):
          await self.websocket.send(message)
  
      async def receive(self):
          return await self.websocket.recv()
  
  class mtest:
      async def start(self):
          try:
              self.wws = await EchoWebsocket()
          finally:
              await self.wws.close()
  
      async def get_ticks(self):
          await self.wws.send(json.dumps({'ticks_history': 'R_50', 'end': 'latest', 'count': 1}))
          return await self.wws.receive()
  
  if __name__ == '__main__':
      a = mtest()
      loop = asyncio.get_event_loop()
      loop.run_until_complete(a.start())
  </code></pre>
  
  <p>And I import it in <code>main.py</code>, where I have the following:</p>
  
  <pre><code>from testws import *
  
  a = mtest()
  print (a.get_ticks())
  print ("this will be printed after the ticks")
  </code></pre>
  
  <p>But it retrieves me the following error:</p>
  
  <pre><code>root@ubupc1:/home/dinocob# python3 test.py
  &lt;coroutine object hello.get_ticks at 0x7f13190a9200&gt;
  test.py:42: RuntimeWarning: coroutine 'mtest.get_ticks' was never awaited
    print (a.get_ticks())
  this will be printed after the ticks
  </code></pre>
  
  <p>What's is going on here? Why I'm not able to access mtest.get_ticks if it has the <code>async</code> word at the begining of <code>def</code>?</p>