本文整理汇总了Python中nanomsg.Socket.send_timeout方法的典型用法代码示例。如果您正苦于以下问题:Python Socket.send_timeout方法的具体用法?Python Socket.send_timeout怎么用?Python Socket.send_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nanomsg.Socket
的用法示例。
在下文中一共展示了Socket.send_timeout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: master_loop
# 需要导入模块: from nanomsg import Socket [as 别名]
# 或者: from nanomsg.Socket import send_timeout [as 别名]
def master_loop():
sock_slave = Socket(PAIR)
sock_slave.bind('tcp://*:%s' % MASTER_PORT)
sock_slave.recv_timeout = 250
#sock_slave.send_buffer_size = 1000
sock_slave.send_timeout = 200
seq = 0
timer = LightTimer()
server = Server()
while True:
ch, value = chanselect([timer.chan, server.chan], [])
#print 'AFTER chanselect', ch is timer.chan, time.time()
if ch is timer.chan:
lights.only(*value)
#print "LIGHTS", value
try:
seq += 1
sock_slave.send('%i %s %s' % (
seq,
CMD_LIGHTS,
' '.join(lights.rev_lookup[led_pin] for led_pin in value)))
except Exception as ex:
#print ex
pass
elif ch is server.chan:
if value[0] == 'status':
slave = None
try:
seq += 1
sock_slave.send('%i PING' % seq)
while True:
slave_msg = sock_slave.recv().split()
if int(slave_msg[0]) == seq:
slave = 'ok'
break
elif int(slave_msg[0]) > seq:
raise Exception('Skipped ping message')
except Exception as ex:
slave = repr(ex)
value[1].put({'loop': 'ok', 'slave': slave})
elif value[0] == 'set_period':
timer.period = value[1]
elif value[0] == 'trip':
timer.trip = True
else:
print "UNKNOWN COMMAND:", value
time.sleep(2)