class_docstr: A task runner that runs an asyncio event loop on a background thread.
class_docstr_tok: ["A","task","runner","that","runs","an","asyncio","event","loop","on","a","background","thread","."]
docstr: Synchronously run a coroutine on a background thread.
docstr_tok: ["Synchronously","run","a","coroutine","on","a","background","thread","."]
code: def run(self, coro: Any) -> Any:
      """Synchronously run a coroutine on a background thread."""
      with self.__lock:
          name = f"{threading.current_thread().name} - runner"
          if self.__io_loop is None:
              self.__io_loop = asyncio.new_event_loop()
              self.__runner_thread = threading.Thread(
                  target=self._runner, daemon=True, name=name
              )
              self.__runner_thread.start()
      fut = asyncio.run_coroutine_threadsafe(coro, self.__io_loop)
      return fut.result(None)
  
imports: from __future__ import annotations
  import asyncio
  import atexit
  import errno
  import inspect
  import sys
  import threading
  import warnings
  from pathlib import Path
  from types import FrameType
  from typing import Any, Awaitable, Callable, TypeVar, cast
label_desc: Use image node_id 4 for calling the _TaskRunner obj's underlying member method code with example usage: obj.run(coro) and returns: fut