class_docstr: A trio loop runner.
class_docstr_tok: ["A","trio","loop","runner","."]
docstr: Run the loop.
docstr_tok: ["Run","the","loop","."]
code: def run(self):
      """Run the loop."""
      old_sig = signal.signal(signal.SIGINT, self.interrupt)
  
      def log_nursery_exc(exc):
          exc = "\n".join(
              traceback.format_exception(
                  type(exc), exc, exc.__traceback__
              )
          )
          logging.error(
              "An exception occurred in a global nursery task.\n%s", exc
          )
  
      async def trio_main():
          """Run the main loop."""
          self._trio_token = trio.lowlevel.current_trio_token()
          async with trio.open_nursery() as nursery:
              # TODO This hack prevents the nursery from cancelling all child
              # tasks when an uncaught exception occurs, but it's ugly.
              nursery._add_exc = log_nursery_exc
              builtins.GLOBAL_NURSERY = (
                  nursery
              )  # type:ignore[attr-defined]
              await trio.sleep_forever()
  
      trio.run(trio_main)
      signal.signal(signal.SIGINT, old_sig)
  
file_path: catboost/contrib/python/ipykernel/py3/ipykernel/trio_runner.py
imports: import builtins
  import logging
  import signal
  import threading
  import traceback
  import warnings
  import trio
label_desc: Use image node_id 4 for calling the TrioRunner obj's underlying member method code with example usage: obj.run() without return types