This repository was archived by the owner on Oct 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,6 +413,12 @@ if __name__ == "__main__":
413413 main()
414414```
415415# Change log
416+ 0.0.7.0 - 25/02/2018
417+ * New reconnection methods implemented. Problem was within ` gevent ` , because connection failures within it are not raised in the main script.
418+ * Added wsaccel for better socket performance.
419+ * Set websocket-client minimum version to 0.47.0
420+
421+ wsaccel
4164220.0.6.4 - 24/02/2018
417423* Fixed order book syncing bug when more than 1 connection is online due to wrong connection/thread name.
418424
Original file line number Diff line number Diff line change 1+ import signalr
2+ import gevent
3+ from ._exceptions import WebSocketConnectionClosedException
4+
5+
6+ class Connection (signalr .Connection ):
7+ def __init__ (self , url , session ):
8+ super (Connection , self ).__init__ (url , session )
9+ self .error_trap = None
10+
11+ def start (self ):
12+ self .starting .fire ()
13+
14+ negotiate_data = self .__transport .negotiate ()
15+ self .token = negotiate_data ['ConnectionToken' ]
16+
17+ listener = self .__transport .start ()
18+
19+ def wrapped_listener ():
20+
21+ # listener()
22+ # gevent.sleep()
23+
24+ try :
25+ listener ()
26+ gevent .sleep ()
27+ except Exception as e :
28+ self .close ()
29+ self .error_trap = e
30+
31+ self .__greenlet = gevent .spawn (wrapped_listener )
32+ self .started = True
33+
34+ def wait (self , timeout = 30 ):
35+ gevent .joinall ([self .__greenlet ], timeout )
36+ if self .error_trap is not None :
37+ return self .error_trap
Original file line number Diff line number Diff line change 4949MSG_ERROR_SOCKET_WEBSOCKETCONNECTIONCLOSED = 'Please report error to ' \
5050 'https://github.com/slazarov/python-bittrex-websocket, ' \
5151 'Error:Init_connection_WebSocketConnectionClosedException'
52+ MSG_ERROR_GEVENT = _CONN_PREFIX + 'Caught {} in gevent. Don\' t worry.'
5253MSG_ERROR_CONN_MISSING_SCHEMA = _CONN_PREFIX + 'Invalid URL: {}'
5354MSG_ERROR_CONN_HTTP = _CONN_PREFIX + 'Failed to establish connection through {}'
Original file line number Diff line number Diff line change 66
77from __future__ import print_function
88
9- from signalr import Connection
9+ # from signalr import Connection
10+ from ._signalr import Connection
1011import logging
1112from abc import ABCMeta , abstractmethod
1213from threading import Thread , current_thread
@@ -330,11 +331,15 @@ def is_next_url():
330331 # Add handlers
331332 corehub .client .on ('updateExchangeState' , self ._on_tick_update )
332333 corehub .client .on ('updateSummaryState' , self ._on_ticker_update )
333- conn .wait (5400 )
334+ run = conn .wait (5400 )
334335 # When we purposely close the connection, the script will exit conn.wait()
335336 # so we need to inform the script that it should not try to reconnect.
336337 if conn_obj .close_me is True :
337338 return
339+ elif run is not None :
340+ logger .error (MSG_ERROR_GEVENT .format (conn_id , type (run )))
341+ self ._empty_conn_id (conn_id )
342+ return
338343 is_next_url ()
339344 except HTTPError :
340345 # Related to wrong url. Will be raised in case Bittrex changes it's url or you touched it!
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ cfscrape>=1.9.4
22signalr-client == 0.0.7
33requests [security ]== 2.18.4
44Events == 0.3
5- websocket-client == 0.46.0
6- gevent >= 1.3a1
5+ websocket-client == 0.47.0
6+ gevent >= 1.3a1
7+ wsaccel >= 0.6.2
Original file line number Diff line number Diff line change 88 'signalr-client==0.0.7' ,
99 'requests[security]==2.18.4' ,
1010 'Events==0.3' ,
11- 'websocket-client>=0.46.0' ,
12- 'gevent>=1.3a1'
11+ 'websocket-client>=0.47.0' ,
12+ 'gevent>=1.3a1' ,
13+ 'wsaccel>=0.6.2'
1314 ]
1415
1516setup (
1617 name = 'bittrex_websocket' ,
17- version = '0.0.6.3 ' ,
18+ version = '0.0.7.0 ' ,
1819 author = 'Stanislav Lazarov' ,
1920 author_email = 's.a.lazarov@gmail.com' ,
2021 license = 'MIT' ,
You can’t perform that action at this time.
0 commit comments