@@ -458,18 +458,25 @@ def create_future(self):
458458        """Create a Future object attached to the loop.""" 
459459        return  futures .Future (loop = self )
460460
461-     def  create_task (self , coro , **  kwargs ):
461+     def  create_task (self , coro , * ,  name = None ,  context = None ):
462462        """Schedule a coroutine object. 
463463
464464        Return a task object. 
465465        """ 
466466        self ._check_closed ()
467-         if  self ._task_factory  is  not   None :
468-             return  self ._task_factory (self , coro , ** kwargs )
467+         if  self ._task_factory  is  None :
468+             task  =  tasks .Task (coro , loop = self , name = name , context = context )
469+             if  task ._source_traceback :
470+                 del  task ._source_traceback [- 1 ]
471+         else :
472+             if  context  is  None :
473+                 # Use legacy API if context is not needed 
474+                 task  =  self ._task_factory (self , coro )
475+             else :
476+                 task  =  self ._task_factory (self , coro , context = context )
477+ 
478+             task .set_name (name )
469479
470-         task  =  tasks .Task (coro , loop = self , ** kwargs )
471-         if  task ._source_traceback :
472-             del  task ._source_traceback [- 1 ]
473480        try :
474481            return  task 
475482        finally :
@@ -483,10 +490,9 @@ def set_task_factory(self, factory):
483490        If factory is None the default task factory will be set. 
484491
485492        If factory is a callable, it should have a signature matching 
486-         '(loop, coro, **kwargs)', where 'loop' will be a reference to the active 
487-         event loop, 'coro' will be a coroutine object, and **kwargs will be 
488-         arbitrary keyword arguments that should be passed on to Task. 
489-         The callable must return a Task. 
493+         '(loop, coro)', where 'loop' will be a reference to the active 
494+         event loop, 'coro' will be a coroutine object.  The callable 
495+         must return a Future. 
490496        """ 
491497        if  factory  is  not   None  and  not  callable (factory ):
492498            raise  TypeError ('task factory must be a callable or None' )
0 commit comments