Overview:
- The method set_name() sets the name of a Task. The method accepts any Python object as the name, not just a string alone.
- The value set by the set_name() method is returned by the get_name() method.
Example:
# Example Python program that uses # Class containing task name and the start # If an instance of TaskInfo is passed # Print the task info # Wrapped coroutine of the task # asyncio.run() will execute the coroutine main # Note: Start time is set on task post scheduling it. # Print the task information await task print("Post await") # Run tasks through asyncio.run() |
Output:
Task Name: 0; Start time: 2022-05-17 13:37:35.193068 Task Name: 1; Start time: 2022-05-17 13:37:35.193282 Task Name: 2; Start time: 2022-05-17 13:37:35.193408 Task Name: 3; Start time: 2022-05-17 13:37:35.193576 Task Name: 4; Start time: 2022-05-17 13:37:35.193717 Post await |