def receiver_proc2(task=None):
# if server is in remote network, add it explicitly
# scheduler = pycos.Pycos.instance()
# yield scheduler.peer('remote.ip')
# yield scheduler.peer(pycos.Location('remote.ip', tcp_port))
rchannel = yield pycos.Channel.locate('2clients')
# this task subscribes to the channel to get messages to server channel
print('server is at %s' % rchannel.location)
if (yield rchannel.subscribe(task)) != 0:
raise Exception('subscription failed')
sender = pycos.Task(sender_proc, rchannel)
while True:
msg = yield task.receive()
print('Received "%s" from %s at %s' %
(msg['msg'], msg['sender'].name, msg['sender'].location))
if msg['msg'] is None and msg['sender'] == sender:
break
yield rchannel.unsubscribe(task)
# pycos.logger.setLevel(logging.DEBUG)
评论列表
文章目录