MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / spin

Function spin

19-concurrency/spinner_async_experiment.py:11–19  ·  view source on GitHub ↗
(msg: str)

Source from the content-addressed store, hash-verified

9import time
10
11async def spin(msg: str) -> None:
12 for char in itertools.cycle(r'\|/-'):
13 status = f'\r{char} {msg}'
14 print(status, flush=True, end='')
15 try:
16 await asyncio.sleep(.1)
17 except asyncio.CancelledError:
18 break
19 print('THIS WILL NEVER BE OUTPUT')
20
21# tag::SPINNER_ASYNC_EXPERIMENT[]
22async def slow() -> int:

Callers 1

supervisorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected