python-poloniex icon indicating copy to clipboard operation
python-poloniex copied to clipboard

websocket not working as expeced for the latest version: _on_close() takes 2 positional arguments but 4 were given

Open OuttaSpaceTime opened this issue 4 years ago • 2 comments
trafficstars

Hey,

I have the following code for my websocket:

    def start_ws(self):
        self.ws = websocket.WebSocketApp(self.wss_url, on_open=self.on_open, on_close=self.on_close,
                                         on_error=self.on_error, on_message=self.on_message)
        self.ws.run_forever()

    def on_open(self, ws):
        logger.info("Binance connection opened")

    def on_close(self, ws):
        logger.warning("Binance connection closed")

    def on_error(self, ws, msg):
        logger.error("Binance connection error: %s", msg)

when I start websocket like so within in my __init__ method:

        threading.Thread(target=self.start_ws).start()

I get the error:

2021-06-21 11:12:18,826 ERROR :: error from callback <bound method Client._on_close of <connectors.client.Client object at 0x0000028C93FDD130>>: _on_close() takes 2 positional arguments but 4 were given

Any idea what is going on here and why is it not working? I also can't see where 4 were given. It only seems be working when I go back version 0.58 How would I have to use it within the latest version?

OuttaSpaceTime avatar Jun 23 '21 07:06 OuttaSpaceTime

Ive updated the master branch, seems websocket-client has dropped support for older versions of python recently. I changed the setup file to require 0.59.0 which is the last version to support the older python versions

s4w3d0ff avatar Jun 25 '21 18:06 s4w3d0ff

I actually worked on python 3.9 though

OuttaSpaceTime avatar Jun 29 '21 12:06 OuttaSpaceTime