@@ -61,12 +61,12 @@ To actually run a coroutine, asyncio provides the following mechanisms:
6161 print(what)
6262
6363 async def main():
64- print(f"started at {time.strftime('%X') }")
64+ print(f"started at {time:%X }")
6565
6666 await say_after(1, 'hello')
6767 await say_after(2, 'world')
6868
69- print(f"finished at {time.strftime('%X') }")
69+ print(f"finished at {time:%X }")
7070
7171 asyncio.run(main())
7272
@@ -90,14 +90,14 @@ To actually run a coroutine, asyncio provides the following mechanisms:
9090 task2 = asyncio.create_task(
9191 say_after(2, 'world'))
9292
93- print(f"started at {time.strftime('%X') }")
93+ print(f"started at {time:%X }")
9494
9595 # Wait until both tasks are completed (should take
9696 # around 2 seconds.)
9797 await task1
9898 await task2
9999
100- print(f"finished at {time.strftime('%X') }")
100+ print(f"finished at {time:%X }")
101101
102102 Note that expected output now shows that the snippet runs
103103 1 second faster than before::
@@ -119,11 +119,11 @@ To actually run a coroutine, asyncio provides the following mechanisms:
119119 task2 = tg.create_task(
120120 say_after(2, 'world'))
121121
122- print(f"started at {time.strftime('%X') }")
122+ print(f"started at {time:%X }")
123123
124124 # The await is implicit when the context manager exits.
125125
126- print(f"finished at {time.strftime('%X') }")
126+ print(f"finished at {time:%X }")
127127
128128 The timing and output should be the same as for the previous version.
129129
@@ -1018,20 +1018,20 @@ Running in Threads
10181018 they were run in the main thread. For example::
10191019
10201020 def blocking_io():
1021- print(f"start blocking_io at {time.strftime('%X') }")
1021+ print(f"start blocking_io at {time:%X }")
10221022 # Note that time.sleep() can be replaced with any blocking
10231023 # IO-bound operation, such as file operations.
10241024 time.sleep(1)
1025- print(f"blocking_io complete at {time.strftime('%X') }")
1025+ print(f"blocking_io complete at {time:%X }")
10261026
10271027 async def main():
1028- print(f"started main at {time.strftime('%X') }")
1028+ print(f"started main at {time:%X }")
10291029
10301030 await asyncio.gather(
10311031 asyncio.to_thread(blocking_io),
10321032 asyncio.sleep(1))
10331033
1034- print(f"finished main at {time.strftime('%X') }")
1034+ print(f"finished main at {time:%X }")
10351035
10361036
10371037 asyncio.run(main())
0 commit comments