slazarov / python-bittrex-websocket

Python websocket for Bittrex (non async).
http://python-bittrex-websocket-docs.readthedocs.io/en/latest/index.html
MIT License
103 stars 38 forks source link

Nonetype object not subscriptable #69

Closed davidfindlay closed 6 years ago

davidfindlay commented 6 years ago

I've started a new project based on the documentation and the pip version 1.0.5:

from bittrex_websocket import BittrexSocket
from time import sleep

# Create an instance of the BittrexSocket class
class MySocket(BittrexSocket):

    # SubscribeToExchangeDeltas is a public call so
    # we need to open/override the on_public channel.
    async def on_public(self, msg):
        print(msg)

# Instantiate MySocket
ws = MySocket()

# Subscribe to Exchange Deltas.
ws.subscribe_to_summary_deltas()

while True:
    # This part of the code runs in MainThread.
    # The while loop will prevent MainThread from terminating
    sleep(1)

I get the following error when I run it:

Exception in thread ControlQueueThread:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bittrex_websocket/websocket_client.py", line 80, in control_queue_handler
    self._handle_subscribe(event)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bittrex_websocket/websocket_client.py", line 178, in _handle_subscribe
    self.invokes.append({'invoke': invoke, 'ticker': payload[0][0]})
TypeError: 'NoneType' object is not subscriptable

^CTraceback (most recent call last):
  File "market_monitor.py", line 23, in <module>
    sleep(1)

Any suggestions? Is it something I'm doing? Thanks,

David

slazarov commented 6 years ago

The code works perfectly fine on my end. However, the code you have shown is for the async version of the socket https://github.com/slazarov/python-bittrex-websocket-aio and you are posting in the non-async. The latest version in github for the aio is 0.0.0.2.8 and for the non-async 1.0.6.1.