Example #1
0
def accept_remote_notify(conn, addr):
    if VERBOSE >= 2:
        print('accept_remote_notify({})'.format(addr))

    cc_key = str(schedaemon_util.recv_buffer(conn))
    try:
        cc_bin = cc_key_map[cc_key]
    except KeyError:
        print('[{}] Unrecognized cc_key: {}'.format(addr, cc_key))
        return

    info = 'ccerbd-compile@{}: {}'.format(addr, cc_key)
    print(info)

    while True:
        try:
            job = schedaemon.ScheduledJob(REMOTE_COMPILE_PRIORITY, info)
        except schedaemon.ExTimeout:
            return

        if not job.acquire():
            return

        reconn_token = os.urandom(RECONN_TOKEN_BYTES)
        with pending_reconnects_lock:
            assert reconn_token not in pending_reconnects
            pending_reconnects[reconn_token] = PendingReconnect(job, cc_bin, addr)

        schedaemon_util.send_buffer(conn, reconn_token)

        schedaemon_util.spawn_thread(thread__pending_compile_timeout, (reconn_token,))

        conn.settimeout(None)
        if not schedaemon_util.recv_poke(conn):
            return
Example #2
0
    remote_gai_str = marshal.dumps(remote_gai)
    schedaemon_util.send_buffer(conn, remote_gai_str)
    schedaemon_util.send_buffer(conn, reconn_token)
    return

########################################

if __name__ == '__main__':
    cc_list = ['cl']
    for cc_bin in cc_list:
        cc_key = get_cc_key(cc_bin)
        cc_key_map[cc_key] = cc_bin
        continue

    ####

    p = subprocess.Popen(('python2.7', 'schedaemon.py'), shell=True)
    # Interestingly, spawning schedaemon here will always succeed.
    # This extra schedaemon will fail to bind to addresses until another schedaemon exits.

    ####

    schedaemon_util.spawn_thread(schedaemon_util.serve_forever, (REMOTE_ADDR, accept_remote))
    schedaemon_util.spawn_thread(schedaemon_util.serve_forever, (LOCAL_ADDR, accept_local))

    ####

    schedaemon_util.sleep_until_keyboard()
    exit(0)
Example #3
0
        self.conn = None
        return

    ####

    def __enter__(self):
        if not self.acquire(None):
            raise ExError()
        return self


    def __exit__(self, ex_type, ex_val, ex_traceback):
        self.cancel()
        return

########################################

if __name__ == '__main__':
    cpu_count = multiprocessing.cpu_count()
    for x in range(cpu_count):
        name = 'slot{}'.format(x)
        t = threading.Thread(target=thread__slot, name=name)
        t.daemon = True
        t.start()
        continue

    schedaemon_util.spawn_thread(schedaemon_util.serve_forever, (ADDR, sched_accept))

    schedaemon_util.sleep_until_keyboard()
    exit(0)