def _add_task(self, task):
        '''Add an already existing task to the task group.'''
        if hasattr(task, '_task_group'):
            raise RuntimeError('task is already part of a group')
        if self._closed:
            raise RuntimeError('task group is closed')
        task._task_group = self
        if task.done():
            self._done.append(task)
        else:
            self._pending.add(task)
            task.add_done_callback(self._on_done)
def _add_task ( self , task ) : if hasattr ( task , '_task_group' ) : raise RuntimeError ( 'task is already part of a group' ) if self . _closed : raise RuntimeError ( 'task group is closed' ) task . _task_group = self if task . done ( ) : self . _done . append ( task ) else : self . _pending . add ( task ) task . add_done_callback ( self . _on_done )
Add an already existing task to the task group.