code: def Task(func, *args, **kwargs):
      
      future = Future()
  
      def handle_exception(typ, value, tb):
          if future.done():
              return False
          future.set_exc_info((typ, value, tb))
          return True
  
      def set_result(result):
          if future.done():
              return
          future.set_result(result)
      with stack_context.ExceptionStackContext(handle_exception):
          func(*args, callback=_argument_adapter(set_result), **kwargs)
      return future
docs: Adapts a callback-based asynchronous function for use in coroutines.
  
      Takes a function (and optional additional arguments) and runs it with
      those arguments plus a ``callback`` keyword argument.  The argument passed
      to the callback is returned as the result of the yield expression.
  
      .. versionchanged:: 4.0
         ``gen.Task`` is now a function that returns a `.Future`, instead of
         a subclass of `YieldPoint`.  It still behaves the same way when
         yielded.