code: def synchronize_task(self, func, *args, **kwargs):
          
  
          async def _runner():
              return func(*args, **kwargs)
  
          return self.emulator.run_task_external(_runner())
docs: Run callable in the rpc thread and wait for it to finish.
  
          The callable ``func`` will be passed into the EmulationLoop and run
          there.  This method will block until ``func`` is finished and
          return/raise whatever that callable returns/raises.
  
          This method is mainly useful for performing an activity that needs to
          be synchronized with the rpc thread for safety reasons.
  
          If this method is called from the rpc thread itself, it will just
          run the task and return its result.
  
          Args:
              func (callable): A method with signature callable(*args, **kwargs),
                  that will be called with the optional *args and **kwargs passed
                  to this method.
              *args: Arguments that will be passed to callable.
              **kwargs: Keyword arguments that will be passed to callable.
  
          Returns:
              object: Whatever callable returns after it runs.