예제 #1
0
 def launch_worker_process(self):
     from calibre.utils.ipc.server import create_listener
     from calibre.utils.ipc.simple_worker import start_pipe_worker
     self.worker_process = p = start_pipe_worker(
         'from {0} import run_main, {1}; run_main({1})'.format(self.__class__.__module__, self.worker_entry_point), stdout=None)
     auth_key = os.urandom(32)
     address, self.listener = create_listener(auth_key)
     eintr_retry_call(p.stdin.write, cPickle.dumps((address, auth_key), -1))
     p.stdin.flush(), p.stdin.close()
     self.control_conn = eintr_retry_call(self.listener.accept)
     self.data_conn = eintr_retry_call(self.listener.accept)
     self.connected.set()
예제 #2
0
    def run(self):
        from calibre.utils.ipc.server import create_listener
        self.auth_key = os.urandom(32)
        self.address, self.listener = create_listener(self.auth_key)
        self.worker_data = cPickle.dumps((self.address, self.auth_key), -1)
        if self.start_worker() is False:
            return

        while True:
            event = self.events.get()
            if event is None or self.shutting_down:
                break
            if self.handle_event(event) is False:
                break
예제 #3
0
파일: pool.py 프로젝트: vijay40/calibre
    def run(self):
        from calibre.utils.ipc.server import create_listener
        self.auth_key = os.urandom(32)
        self.address, self.listener = create_listener(self.auth_key)
        self.worker_data = cPickle.dumps((self.address, self.auth_key), -1)
        if self.start_worker() is False:
            return

        while True:
            event = self.events.get()
            if event is None or self.shutting_down:
                break
            if self.handle_event(event) is False:
                break
예제 #4
0
파일: worker.py 프로젝트: Mymei2/calibre
 def launch_worker_process(self):
     from calibre.utils.ipc.server import create_listener
     from calibre.utils.ipc.pool import start_worker
     self.worker_process = p = start_worker(
         'from {0} import run_main, {1}; run_main({1})'.format(self.__class__.__module__, self.worker_entry_point))
     auth_key = os.urandom(32)
     address, self.listener = create_listener(auth_key)
     eintr_retry_call(p.stdin.write, cPickle.dumps((address, auth_key), -1))
     p.stdin.flush(), p.stdin.close()
     self.control_conn = eintr_retry_call(self.listener.accept)
     self.data_conn = eintr_retry_call(self.listener.accept)
     self.data_thread = t = Thread(name='CWData', target=self.handle_data_requests)
     t.daemon = True
     t.start()
     self.connected.set()
예제 #5
0
def create_worker(env, priority='normal', cwd=None, func='main'):
    from calibre.utils.ipc.server import create_listener
    auth_key = os.urandom(32)
    address, listener = create_listener(auth_key)

    env = dict(env)
    env.update({
        'CALIBRE_WORKER_ADDRESS': hexlify(cPickle.dumps(listener.address, -1)),
        'CALIBRE_WORKER_KEY': hexlify(auth_key),
        'CALIBRE_SIMPLE_WORKER': 'calibre.utils.ipc.simple_worker:%s' % func,
    })

    w = Worker(env)
    w(cwd=cwd, priority=priority)
    return listener, w
예제 #6
0
def create_worker(env, priority='normal', cwd=None, func='main'):
    from calibre.utils.ipc.server import create_listener
    auth_key = os.urandom(32)
    address, listener = create_listener(auth_key)

    env = dict(env)
    env.update({
        'CALIBRE_WORKER_ADDRESS': environ_item(as_hex_unicode(msgpack_dumps(address))),
        'CALIBRE_WORKER_KEY': environ_item(as_hex_unicode(auth_key)),
        'CALIBRE_SIMPLE_WORKER': environ_item('calibre.utils.ipc.simple_worker:%s' % func),
    })

    w = Worker(env)
    w(cwd=cwd, priority=priority)
    return listener, w
예제 #7
0
파일: worker.py 프로젝트: pdiazs/calibre
 def launch_worker_process(self):
     from calibre.utils.ipc.server import create_listener
     from calibre.utils.ipc.pool import start_worker
     self.worker_process = p = start_worker(
         'from {0} import run_main, {1}; run_main({1})'.format(self.__class__.__module__, self.worker_entry_point))
     auth_key = os.urandom(32)
     address, self.listener = create_listener(auth_key)
     eintr_retry_call(p.stdin.write, cPickle.dumps((address, auth_key), -1))
     p.stdin.flush(), p.stdin.close()
     self.control_conn = eintr_retry_call(self.listener.accept)
     self.data_conn = eintr_retry_call(self.listener.accept)
     self.data_thread = t = Thread(name='CWData', target=self.handle_data_requests)
     t.daemon = True
     t.start()
     self.connected.set()
예제 #8
0
def create_worker(env, priority='normal', cwd=None, func='main'):
    from calibre.utils.ipc.server import create_listener
    auth_key = os.urandom(32)
    address, listener = create_listener(auth_key)

    env = dict(env)
    env.update({
        'CALIBRE_WORKER_ADDRESS': environ_item(as_hex_unicode(msgpack_dumps(address))),
        'CALIBRE_WORKER_KEY': environ_item(as_hex_unicode(auth_key)),
        'CALIBRE_SIMPLE_WORKER': environ_item('calibre.utils.ipc.simple_worker:%s' % func),
    })

    w = Worker(env)
    w(cwd=cwd, priority=priority)
    return listener, w
예제 #9
0
def create_worker(env, priority='normal', cwd=None, func='main'):
    from calibre.utils.ipc.server import create_listener
    auth_key = os.urandom(32)
    address, listener = create_listener(auth_key)

    env = dict(env)
    env.update({
                'CALIBRE_WORKER_ADDRESS' :
                    hexlify(cPickle.dumps(listener.address, -1)),
                'CALIBRE_WORKER_KEY' : hexlify(auth_key),
                'CALIBRE_SIMPLE_WORKER':
                            'calibre.utils.ipc.simple_worker:%s' % func,
            })

    w = Worker(env)
    w(cwd=cwd, priority=priority)
    return listener, w