def _read_out(self): stream = PluginIPCStream() while self._process_running: exit_code = self._proc.poll() if exit_code is not None: self.logger('[Runner] Stopped with exit code {0}'.format(exit_code)) self._process_running = False break line = '' while line == '': line = self._proc.stdout.readline().strip() try: response = stream.feed(line) if response is None: continue except Exception as ex: self.logger('[Runner] Exception while parsing output: {0}'.format(ex)) continue if response['cid'] == 0: self._handle_async_response(response) elif response['cid'] == self._cid: self._response_queue.put(response) else: self.logger('[Runner] Received message with unknown cid: {0}'.format(response))
def _wait_and_read_command(): stream = PluginIPCStream() line = '' while line == '': line = sys.stdin.readline().strip() try: response = stream.feed(line) if response is not None: return response except Exception as ex: IO._log( 'Exception in _wait_and_read_command: Could not decode stdin: {0}' .format(ex))