Пример #1
0
def register(node, config, instance_config):
    for name, handler, schedule in [
            ('join', join, False),
            ('depart', depart, False),
            ('say', say, False),
            ('wait', wait, True)]:
        node.accept_rpc(
                config.service,
                instance_config.mask,
                instance_config.value,
                name,
                functools.partial(handler, node, config),
                schedule=schedule)

    for name, handler in [
            ('peer_join', peer_join),
            ('peer_depart', peer_depart),
            ('peer_say', peer_say)]:
        for pubval in instance_config.pubvals:
            node.accept_publish(
                    config.service,
                    instance_config.pubmask,
                    pubval,
                    name,
                    functools.partial(handler, node),
                    schedule=False)

    greenhouse.set_ignore_interrupts()
Пример #2
0
def greenhouse_serve():
    greenhouse.set_ignore_interrupts(1)
    servsock = greenhouse.Socket()
    servsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    servsock.bind(("127.0.0.1", 8000))
    servsock.listen(socket.SOMAXCONN)

    try:
        while 1:
            client, addr = servsock.accept()
            greenhouse.schedule(greenhouse_handler, (client, ))
    except GoAway:
        pass
Пример #3
0
def greenhouse_serve():
    greenhouse.set_ignore_interrupts(1)
    servsock = greenhouse.Socket()
    servsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    servsock.bind(("127.0.0.1", 8000))
    servsock.listen(socket.SOMAXCONN)

    try:
        while 1:
            client, addr = servsock.accept()
            greenhouse.schedule(greenhouse_handler, (client,))
    except GoAway:
        pass
Пример #4
0
                try:
                    yak.depart(roomname)
                except Exception, exc:
                    pass
            finished.set()

    def int_handler(signum, frame):
        greenhouse.end(speaker_glet)
    signal.signal(signal.SIGINT, int_handler)

    yak.join(roomname)
    joined.set()

    # even with the SIGINT handler in place, the epoll wait underneath
    # the greenhouse.stdin.readline() call will get EINTR first
    greenhouse.set_ignore_interrupts()

    finished.wait()


@command('join')
def join(options, roomname, username):
    conf = configs.get_configs(options.configfile)
    yak = client.Yakity(conf, client.prepare_client(
        conf, room_hint=roomname, user_hint=username), username)
    yak.join(roomname)

@command('depart')
def depart(options, roomname, username):
    conf = configs.get_configs(options.configfile)
    yak = client.Yakity(conf, client.prepare_client(