slazarov / python-signalr-client

SignalR client for python based on asyncio.
MIT License
33 stars 22 forks source link

Example not working #5

Closed meister245 closed 6 years ago

meister245 commented 6 years ago

Hi, I wanted to try out the library, but it's not working for me. I copy pasted your example code under sample usage. I'm using the 0.0.1.5 version from PyPi.

Traceback (most recent call last):
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py", line 67, in consumer_handler
    async for message in ws:
TypeError: 'async for' requires an object with __aiter__ method, got WebSocketClientProtocol

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bittrex.py", line 51, in <module>
    connection.start()
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/_connection.py", line 36, in start
    self.__transport.start()
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py", line 39, in start
    self.ws_loop.run_until_complete(self.socket(self.ws_loop))
  File "uvloop/loop.pyx", line 1364, in uvloop.loop.Loop.run_until_complete
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py", line 53, in socket
    await self.handler(ws)
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py", line 60, in handler
    loop=self.ws_loop, return_exceptions=False)
  File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py", line 72, in consumer_handler
    raise Exception
Exception
Task was destroyed but it is pending!
task: <Task pending coro=<Transport.producer_handler() running at /home/meister245/virtualenv/py3_virtual/lib/python3.5/site-packages/signalr_aio/transports/_transport.py:77> wait_for=<Future pending cb=[Task._wakeup()]> cb=[gather.<locals>._done_callback(1)() at /usr/lib/python3.5/asyncio/tasks.py:637]>
slazarov commented 6 years ago

There were some missing async/await statements which might have caused the problem. Please update through github. If it doesn't work, please try with Python3.6 and post back.

meister245 commented 6 years ago

hey, thanks for looking into it, I reinstalled the package and now I'm on version 0.0.1.6.1 and it's working correctly 👍

slazarov commented 6 years ago

Glad to hear that @meister245, closing the issue then.