def do_workflow(self, notebook, ident, parent): shell = self.shell reply_content = {} if (_asyncio_runner and shell.loop_runner is _asyncio_runner and asyncio.get_event_loop().is_running()): coro = shell.run_workflow(notebook) coro_future = asyncio.ensure_future(coro) with self._cancel_on_sigint(coro_future): try: res = yield coro_future finally: shell.events.trigger('post_execute') else: coro = shell.run_workflow(notebook) if shell.trio_runner: runner = shell.trio_runner else: runner = shell.loop_runner res = runner(coro) # Send outputs to cell streams for cell_name, content in res.result.items(): self.session.send(self.iopub_thread, 'stream', content={ 'name': cell_name, 'text': content }, parent=extract_header(parent), ident=ident) # Send reply message if res.error_before_exec is not None: err = res.error_before_exec else: err = res.error_in_exec if res.success: reply_content['status'] = 'ok' else: reply_content['status'] = 'error' # noinspection PyProtectedMember reply_content.update({ 'traceback': shell._last_traceback or [], 'ename': str(type(err).__name__), 'evalue': safe_unicode(err), }) reply_content['execution_count'] = shell.execution_count - 1 reply_content['payload'] = shell.payload_manager.read_payload() shell.payload_manager.clear_payload() return reply_content
def set_parent(self, parent): """Set the parent for outbound messages.""" self.parent_header = extract_header(parent)
def set_parent(self, parent): self.parent_header = extract_header(parent)