Skip to content

Commit

Permalink
vn.rpc中的zmq socket接收数据前,使用poll等待
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxy123 committed Dec 21, 2016
1 parent 49f1a7f commit 0d3fceb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vn.rpc/vnrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ def stop(self):
def run(self):
"""服务器运行函数"""
while self.__active:
# 使用poll来等待事件到达,等待1秒(1000毫秒)
if not self.__socketREP.poll(1000):
continue

# 从请求响应socket收取请求数据
reqb = self.__socketREP.recv()

Expand Down Expand Up @@ -266,6 +270,10 @@ def stop(self):
def run(self):
"""客户端运行函数"""
while self.__active:
# 使用poll来等待事件到达,等待1秒(1000毫秒)
if not self.__socketSUB.poll(1000):
continue

# 从订阅socket收取广播数据
topic, datab = self.__socketSUB.recv_multipart()

Expand Down

0 comments on commit 0d3fceb

Please sign in to comment.