async def insert(self, task: Task) -> None:
if not isinstance(task, Task):<EOL><INDENT>task = task()<EOL><DEDENT>if task.name not in self.all_tasks:<EOL><INDENT>task.tasky = self<EOL>self.all_tasks[task.name] = task<EOL>await task.init()<EOL><DEDENT>elif task != self.all_tasks[task.name]:<EOL><INDENT>raise Exception('<STR_LIT>' % task.name)<EOL><DEDENT>if task.enabled:<EOL><INDENT>task.task = asyncio.ensure_future(self.start_task(task))<EOL>self.running_tasks.add(task)<EOL><DEDENT>else:<EOL><INDENT>task.task = None<EOL><DEDENT>return task<EOL>
Insert the given task class into the Tasky event loop.