Any one familiar with websocket-client? https://github.com/websocket-client/websocket-client
I think my issue maybe more python syntax than any thing.
I was using ws=Websocket() and my 'import websocket'. This seemed to be working.
But the instillation was magic. I tried "pip install websocket" and it would error out. Then I did "pip install websocket-client". That seemed to work and I started debugging my code.
I am using PyCharm and it asked if I wanted to include the import into my __setup__.py I said yes and it quit.
[Edit]
Just saw this pip command and thought it might be relevant.
I think my issue maybe more python syntax than any thing.
I was using ws=Websocket() and my 'import websocket'. This seemed to be working.
But the instillation was magic. I tried "pip install websocket" and it would error out. Then I did "pip install websocket-client". That seemed to work and I started debugging my code.
I am using PyCharm and it asked if I wanted to include the import into my __setup__.py I said yes and it quit.
[Edit]
Just saw this pip command and thought it might be relevant.
Output:(venv) C:\Users\paul\PycharmProjects\pyalmondplus>pip list
Package Version
---------------- -------
atomicwrites 1.1.5
attrs 18.1.0
click 6.7
colorama 0.3.9
more-itertools 4.2.0
pip 10.0.1
pluggy 0.6.0
py 1.5.4
pytest 3.6.3
pytest-runner 4.2
ruamel.yaml 0.15.42
setuptools 39.1.0
six 1.11.0
websocket-client 0.48.0
websockets 5.0.1
(venv) C:\Users\paul\PycharmProjects\pyalmondplus>
In the more info than you care, here is the code snippet.# -*- coding: utf-8 -*- import threading import websocket from websocket-client import json import time class PyAlmondPlus: def __init__(self, api_url, event_callback=None): self.api_url = api_url self.ws = None self.receive_task = None self.event_callback = event_callback self.keep_running = True self.client_running = False t = threading.Thread(target=self.api_dispatcher, args=()) t.start() def __del__(self): print("Delete started") if self.ws is not None: self.stop() print("deleted") def connect(self): print("connecting") if self.ws is None: print("opening socket ("+self.api_url+')') self.ws = WebSocket() self.ws.connect(self.api_url) print("Socket connected") def disconnect(self): pass def get_device_list(self): my_message = '{"MobileInternalIndex":"231234","CommandType":"DeviceList"}' self.send(my_message) def send(self, message): print("sending "+message) self.ws.send(message) def receive(self): print("receive started") try: recv_data = self.ws.recv() print(recv_data) except Exception as e: print("Error") print("**************************\n" + str(e) + "\n" + "**************************") self.ws = None return print("receive ended") if self.keep_running: self.receive() def api_dispatcher(self): while self.keep_running: print("Dispatcher Start") if self.client_running: print("Client is running") if self.ws is None: print("self.ws is none") self.connect() self.receive() def start(self): self.client_running = True def stop(self): print("Stop 1") if self.ws is not None: self.ws.close() self.ws = None self.keep_running = False print("Stop 2")