Overview:
-
The method get_name() returns the name of a Task given to it during its creation.
-
The name could have been set through the name parameter of the asyncio.create_task() or through the task.set_name() method.
-
Even if a name is not explicitly given through the name parameter of the asyncio.create_task() method, asyncio provides a default name for the created Task object.
Example:
# Example Python program that uses the import asyncio # A simple coroutine in Python # Print the name of the task # Create an asyncio task and await for it # Print task names # Execute tasks through asyncio.run() |
Output:
Simple task Yet another simple task |