[Mod] WebSocket改名为Websocket
This commit is contained in:
parent
d68529dacd
commit
cab8fd1e0e
@ -2,10 +2,10 @@
|
||||
import unittest
|
||||
|
||||
from Promise import Promise
|
||||
from vnpy.api.websocket import WebSocketClient
|
||||
from vnpy.api.websocket import WebsocketClient
|
||||
|
||||
|
||||
class TestWebsocketClient(WebSocketClient):
|
||||
class TestWebsocketClient(WebsocketClient):
|
||||
|
||||
def __init__(self):
|
||||
host = 'wss://echo.websocket.org'
|
||||
|
@ -88,7 +88,7 @@ class RestClient(object):
|
||||
self.urlBase = urlBase
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def _generateSession(self):
|
||||
def _createSession(self):
|
||||
""""""
|
||||
return requests.session()
|
||||
|
||||
@ -127,7 +127,7 @@ class RestClient(object):
|
||||
params=None, # type: dict
|
||||
data=None, # type: dict
|
||||
headers=None, # type: dict
|
||||
onFailed=None, # type: Callable[[dict, Request], Any]
|
||||
onFailed=None, # type: Callable[[int, Request], Any]
|
||||
extra=None # type: Any
|
||||
): # type: (...)->Request
|
||||
"""
|
||||
@ -151,7 +151,7 @@ class RestClient(object):
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def _run(self):
|
||||
session = self._generateSession()
|
||||
session = self._createSession()
|
||||
while self._active:
|
||||
try:
|
||||
request = self._queue.get(timeout=1)
|
||||
|
@ -11,7 +11,7 @@ import websocket
|
||||
from threading import Lock, Thread
|
||||
|
||||
|
||||
class WebSocketClient(object):
|
||||
class WebsocketClient(object):
|
||||
"""
|
||||
Websocket API
|
||||
|
||||
@ -36,8 +36,6 @@ class WebSocketClient(object):
|
||||
def __init__(self):
|
||||
"""Constructor"""
|
||||
self.host = None # type: str
|
||||
|
||||
self._createConnection = websocket.create_connection
|
||||
|
||||
self._ws_lock = Lock()
|
||||
self._ws = None # type: websocket.WebSocket
|
||||
@ -70,7 +68,8 @@ class WebSocketClient(object):
|
||||
"""
|
||||
self._active = False
|
||||
self._disconnect()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def join(self):
|
||||
"""
|
||||
等待所有工作线程退出
|
||||
@ -100,6 +99,10 @@ class WebSocketClient(object):
|
||||
if self._active:
|
||||
self._disconnect()
|
||||
self._connect()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def _createConnection(self, *args, **kwargs):
|
||||
return websocket.create_connection(*args, **kwargs)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def _connect(self):
|
@ -1 +1 @@
|
||||
from .WebSocketClient import WebSocketClient
|
||||
from .WebsocketClient import WebsocketClient
|
||||
|
Loading…
Reference in New Issue
Block a user