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

Function spin

19-concurrency/primes/spinner_prime_async_nap.py:31–40  ·  view source on GitHub ↗
(msg: str)

Source from the content-addressed store, hash-verified

29
30
31async def spin(msg: str) -> None:
32 for char in itertools.cycle(r'\|/-'):
33 status = f'\r{char} {msg}'
34 print(status, flush=True, end='')
35 try:
36 await asyncio.sleep(.1)
37 except asyncio.CancelledError:
38 break
39 blanks = ' ' * len(status)
40 print(f'\r{blanks}\r', end='')
41
42async def check(n: int) -> int:
43 return await is_prime(n)

Callers 1

supervisorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected