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

Function supervisor

19-concurrency/primes/spinner_prime_async_nap.py:45–50  ·  view source on GitHub ↗
(n: int)

Source from the content-addressed store, hash-verified

43 return await is_prime(n)
44
45async def supervisor(n: int) -> int:
46 spinner = asyncio.create_task(spin('thinking!'))
47 print('spinner object:', spinner)
48 result = await check(n)
49 spinner.cancel()
50 return result
51
52def main() -> None:
53 n = 5_000_111_000_222_021

Callers 1

mainFunction · 0.70

Calls 2

spinFunction · 0.70
checkFunction · 0.70

Tested by

no test coverage detected