def create(self): if self._connected is not None: return self._connected MODULE.info('Starting new module process: %s' % (self.module,)) self.socket = self.get_socket_path() args = [ MODULE_COMMAND, '-l', self.module_locale, '-d', str(self.module_debug_level), self.socket, self.module ] MODULE.info('Module process: %s' % (' '.join(args))) self.process = Popen(args, executable=MODULE_COMMAND, shell=False) # TODO: stdout, stderr connect = LoopingCall(self.connect) connect.a = (connect,) # twisteds arguments self._connected = connect.start(0.05) return self._connected
def failed(failure): MODULE.error('Creating ModuleProcess failed...') return response.errback(failure.value)
def success(result): if not self.proxy: MODULE.error('Waiting for socket creation timed out... %r' % (result,)) raise CouldNotConnect('The ModuleProcess connection failed due to a internal timeout') return response.callback(result)
def request(_): MODULE.info('Passing request %r to module process' % (uri,)) return self.proxy.request(method, uri, headers, body)