class_docstr: Wrapper class that defines synchronous `_sync` method wrappers
  
  around async-native methods.
  
  Every coroutine method automatically gets an `_sync` alias
  that runs it synchronously.
class_docstr_tok: ["Wrapper","class","that","defines","synchronous","`","_sync","`","method","wrappers","around","async-native","methods",".","Every","coroutine","method","automatically","gets","an","`","_sync","`","alias","that","runs","it","synchronously","."]
docstr: Run a method synchronously
  
  Uses asyncio.run if asyncio is not running,
  otherwise puts it in a background thread
docstr_tok: ["Run","a","method","synchronously","Uses","asyncio.run","if","asyncio","is","not","running",",","otherwise","puts","it","in","a","background","thread"]
code: def _synchronize(self, async_f, *args, **kwargs):
      """Run a method synchronously
  
      Uses asyncio.run if asyncio is not running,
      otherwise puts it in a background thread
      """
      try:
          loop = asyncio.get_running_loop()
      except RuntimeError:
          # not in a running loop
          loop = None
      if loop:
          return self._in_thread(async_f, *args, **kwargs)
      else:
          return _asyncio_run(async_f(*args, **kwargs))
  
file_path: ipyparallel/ipyparallel/_async.py
imports: import asyncio
  import concurrent.futures
  import inspect
  import threading
  from functools import partial
  from tornado.ioloop import IOLoop
label_desc: Use image node_id 3 for calling the AsyncFirst obj's underlying member method code with example usage: obj._synchronize(async_f) and returns: self, _asyncio_run