ohenrik / bitfinex

A Python client for the Bitfinex API
MIT License
58 stars 32 forks source link

Can't normally finish program with few websockets #25

Closed Flowelfox closed 5 years ago

Flowelfox commented 5 years ago

I created wssclient and subscribed to candles with different symbols.

ws = WssClient()
ws.subscribe_to_candles(...)
ws.start()

After calling ws.close() my program can't finish it work because 'PoolThread-twisted.internet.reactor-0' does not stops. For proper work i must stop this thread by myself calling

from twisted.internet import reactor
reactor.stop()

Someone else has this issue?

ohenrik commented 5 years ago

This is correct, I'll add this to the stop method so that is properly closes the running reactor.

Also I'm working on a version for python 3.7 and up that uses asyncio and websockets that is much cleaner and uses await.

ohenrik commented 5 years ago

I have now added the method stop() to version 1.1.2: https://bitfinex.readthedocs.io/en/latest/websocket.html#bitfinex.websockets.client.WssClient.stop

It will try to close all connections and will finally stop the reactor and properly exit the program.