修改vn.rpc的实现,对外暴露run函数
This commit is contained in:
parent
4bff52823c
commit
106985695d
@ -123,7 +123,7 @@ class RpcServer(RpcObject):
|
||||
|
||||
# 工作线程相关
|
||||
self.__active = False # 服务器的工作状态
|
||||
self.__thread = threading.Thread(target=self.__run) # 服务器的工作线程
|
||||
self.__thread = threading.Thread(target=self.run) # 服务器的工作线程
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def start(self):
|
||||
@ -132,6 +132,7 @@ class RpcServer(RpcObject):
|
||||
self.__active = True
|
||||
|
||||
# 启动工作线程
|
||||
if not self.__thread.isAlive():
|
||||
self.__thread.start()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -141,11 +142,12 @@ class RpcServer(RpcObject):
|
||||
self.__active = False
|
||||
|
||||
# 等待工作线程退出
|
||||
if self.__thread.isAlive():
|
||||
self.__thread.join()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __run(self):
|
||||
"""连续运行函数"""
|
||||
def run(self):
|
||||
"""服务器运行函数"""
|
||||
while self.__active:
|
||||
# 从请求响应socket收取请求数据
|
||||
reqb = self.__socketREP.recv()
|
||||
@ -208,7 +210,7 @@ class RpcClient(RpcObject):
|
||||
|
||||
# 工作线程相关,用于处理服务器推送的数据
|
||||
self.__active = False # 客户端的工作状态
|
||||
self.__thread = threading.Thread(target=self.__run) # 客户端的工作线程
|
||||
self.__thread = threading.Thread(target=self.run) # 客户端的工作线程
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __getattr__(self, name):
|
||||
@ -247,6 +249,7 @@ class RpcClient(RpcObject):
|
||||
self.__active = True
|
||||
|
||||
# 启动工作线程
|
||||
if not self.__thread.isAlive():
|
||||
self.__thread.start()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -256,11 +259,12 @@ class RpcClient(RpcObject):
|
||||
self.__active = False
|
||||
|
||||
# 等待工作线程退出
|
||||
if self.__thread.isAlive():
|
||||
self.__thread.join()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __run(self):
|
||||
"""连续运行函数"""
|
||||
def run(self):
|
||||
"""客户端运行函数"""
|
||||
while self.__active:
|
||||
# 从订阅socket收取广播数据
|
||||
topic, datab = self.__socketSUB.recv_multipart()
|
||||
|
Loading…
Reference in New Issue
Block a user