def main(serveraddr): vim = attach_vim(serveraddr) from denite.child import Child from denite.util import error_tb stdout = sys.stdout sys.stdout = RedirectStream(lambda data: vim.out_write(data)) sys.stderr = RedirectStream(lambda data: vim.err_write(data)) try: child = Child(vim) child.main_loop(stdout) except Exception as exc: error_tb(vim, 'Error in child: %r' % exc)
def _put(self, name: str, args: typing.List[typing.Any]) -> str: if not self._hnd: return '' queue_id = str(time.time()) msg = self._packer.pack({ 'name': name, 'args': args, 'queue_id': queue_id }) self._queue_in.put(msg) if self._stdin: try: while not self._queue_in.empty(): self._stdin.write(self._queue_in.get_nowait()) except BrokenPipeError: error_tb(self._vim, 'Crash in child process') error(self._vim, 'stderr=' + str(self._proc.read_error())) self._hnd = None return queue_id