@@ -458,25 +458,18 @@ 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 , * , name = None , context = None ):
461+ def create_task (self , coro , ** kwargs ):
462462 """Schedule a coroutine object.
463463
464464 Return a task object.
465465 """
466466 self ._check_closed ()
467467 if self ._task_factory is None :
468- task = tasks .Task (coro , loop = self , name = name , context = context )
468+ task = tasks .Task (coro , loop = self , ** kwargs )
469469 if task ._source_traceback :
470470 del task ._source_traceback [- 1 ]
471471 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 )
479-
472+ task = self ._task_factory (self , coro , ** kwargs )
480473 try :
481474 return task
482475 finally :
@@ -490,9 +483,10 @@ def set_task_factory(self, factory):
490483 If factory is None the default task factory will be set.
491484
492485 If factory is a callable, it should have a signature matching
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.
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.
496490 """
497491 if factory is not None and not callable (factory ):
498492 raise TypeError ('task factory must be a callable or None' )
0 commit comments