本文整理汇总了Python中multiprocessing.connection.Client.poll方法的典型用法代码示例。如果您正苦于以下问题:Python Client.poll方法的具体用法?Python Client.poll怎么用?Python Client.poll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.connection.Client
的用法示例。
在下文中一共展示了Client.poll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import poll [as 别名]
class UIListener:
def __init__(self, address, port, authkey):
self.client = Client((address, port), authkey=authkey)
def get_args(self, n):
return [self.client.recv() if self.client.poll(0.5) else None for _ in range(n)]
def listenloop(self):
keepalive = True
try:
while keepalive:
while self.client.poll():
data = self.client.recv()
print('{}: {}'.format('x64' if utils.is64bit() else 'x86', data))
if data == 'close':
keepalive = False
else:
func = _interface[data]
self.client.send(func(*self.get_args(func.__code__.co_argcount)))
print('{}: sent response to {}'.format('x64' if utils.is64bit() else 'x86', data))
time.sleep(0.05)
except EOFError or ConnectionError:
pass
self.client.close()
示例2: CliClient
# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import poll [as 别名]
class CliClient(cmd.Cmd):
def __init__(self,address,id):
self.id = id
self.connection = Client(address, authkey='secret password')
cmd.Cmd.__init__(self)
def onecmd(self,line):
self.connection.send(("creator",line))
while self.connection.poll(0.1):
print self.connection.recv()
示例3: ProcClient
# 需要导入模块: from multiprocessing.connection import Client [as 别名]
# 或者: from multiprocessing.connection.Client import poll [as 别名]
class ProcClient(threading.Thread):
def __init__(self, addr, authkey):
threading.Thread.__init__(self)
self.bus = None
self.addr = addr
self.authkey = authkey
self.conn = None
self.running = False
self.setDaemon(True)
def run(self):
self.conn = None
for i in range(0, 3):
self.bus.log("Starting process client connection to: %s:%d" % self.addr)
try:
self.conn = Client(self.addr, authkey=self.authkey)
break
except:
self.bus.log("", traceback=True)
time.sleep(10.0)
if not self.conn:
self.bus.log("Failed to connect to %s:%d" % self.addr)
return
self.running = True
while self.running:
try:
if self.conn.poll(1.0):
print self.conn.recv()
except IOError:
self.stop()
break
def stop(self):
if not self.running:
return
self.bus.log("Stopping process client connection")
if self.conn:
self.running = False
self.conn.close()
self.conn = None
def send(self, data):
self.conn.send(data)
def recv(self):
return self.conn.recv()