def __init__(self, **kwargs): super().__init__(**kwargs) self._eventloop = IOLoop.current() self._key = generate_id(size=32).encode('utf-8') self._execution_lock = Lock(loop=self._eventloop.asyncio_loop) self._inner_state_lock = Lock(loop=self._eventloop.asyncio_loop) self._dep_tracker = DependencyTracker() self._exec_unit_container = ExecUnitContainer() self.formatter = DisplayFormatter() self.manager_ns = BuiltInManager() self.manager_ns.global_ns['__builtins__'] = builtin_mods.__dict__ self.manager_ns.global_ns['show_graph'] = self._show_graph self._execution_ctx = Executor(self._exec_unit_container, manager_ns=self.manager_ns) self.KernelTB = ultratb.AutoFormattedTB(mode='Plain', color_scheme='LightBG', tb_offset=1, debugger_cls=None) self._execution_queue = Queue(loop=self._eventloop.asyncio_loop) builtin_mods.show_graph = self._show_graph # mapping from variable name (target id) to (request id, generator # object) self._registered_generators = dict() self._eventloop.spawn_callback(self._execution_loop)
def setup_exceptions(mode='Plain', color_scheme='Neutral'): """If it is present, uses IPython's ultratb to make exceptions more readable.""" try: from IPython.core import ultratb sys.excepthook = ultratb.AutoFormattedTB(mode=mode, color_scheme=color_scheme) except ImportError: pass
def __init__(self, loader: InspectLoader): self.user_ns = {} self.loader = loader self.excepthook = sys.excepthook self.InteractiveTB = ultratb.AutoFormattedTB(mode='Plain', color_scheme='LightBG', tb_offset=1, debugger_cls=None) self.SyntaxTB = ultratb.SyntaxTB(color_scheme='NoColor')
def __init__(self, **kwargs): super().__init__(**kwargs) self._key = generate_id(size=32).encode('utf-8') self._eventloop = IOLoop.current().asyncio_loop self._inner_state_lock = Lock(loop=self._eventloop) self._dep_tracker = DependencyTracker() self._exec_unit_container = ExecUnitContainer() self.formatter = DisplayFormatter() self.ns_manager = BuiltInManager() self.initialize_builtins() self._execution_ctx = Executor(self._exec_unit_container, ns_manager=self.ns_manager) self.KernelTB = ultratb.AutoFormattedTB(mode='Plain', color_scheme='LightBG', tb_offset=1, debugger_cls=None) # mapping from variable name (target id) to (request id, generator # object) self._registered_generators = dict()
def __init__(self, tb_offset=0, color='Neutral'): self.syntax_tb = ultratb.SyntaxTB(color_scheme=color) self.interactive_tb = ultratb.AutoFormattedTB(mode='Context', color_scheme=color, tb_offset=tb_offset)