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()
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()
def launch_worker_process(self): from calibre.utils.ipc.pool import start_worker control_a, control_b = Pipe() data_a, data_b = Pipe() with control_a, data_a: pass_fds = control_a.fileno(), data_a.fileno() self.worker_process = p = start_worker( 'from {0} import run_main, {1}; run_main({2}, {3}, {1})'. format(self.__class__.__module__, self.worker_entry_point, *pass_fds), pass_fds) p.stdin.close() self.control_conn = control_b self.data_conn = data_b self.data_thread = t = Thread(name='CWData', target=self.handle_data_requests) t.daemon = True t.start() self.connected.set()