[Mod] WebSocket改名为Websocket

This commit is contained in:
nanoric 2018-10-23 21:29:20 -04:00
parent d68529dacd
commit cab8fd1e0e
4 changed files with 13 additions and 10 deletions

View File

@ -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'

View File

@ -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)

View File

@ -11,7 +11,7 @@ import websocket
from threading import Lock, Thread
class WebSocketClient(object):
class WebsocketClient(object):
"""
Websocket API
@ -37,8 +37,6 @@ class WebSocketClient(object):
"""Constructor"""
self.host = None # type: str
self._createConnection = websocket.create_connection
self._ws_lock = Lock()
self._ws = None # type: websocket.WebSocket
@ -71,6 +69,7 @@ class WebSocketClient(object):
self._active = False
self._disconnect()
#----------------------------------------------------------------------
def join(self):
"""
等待所有工作线程退出
@ -101,6 +100,10 @@ class WebSocketClient(object):
self._disconnect()
self._connect()
#----------------------------------------------------------------------
def _createConnection(self, *args, **kwargs):
return websocket.create_connection(*args, **kwargs)
#----------------------------------------------------------------------
def _connect(self):
""""""

View File

@ -1 +1 @@
from .WebSocketClient import WebSocketClient
from .WebsocketClient import WebsocketClient