Type the remaining niche examples
Finish the examples-typing sweep with the last non-docs-visible scripts: `-> None` on the two `trio/` behavior-demo mains (plus a `trio.TaskStatus` on `hold_lock_forever`) and nursery/portal typing on `integration/mpi4py/inherit_parent_main.py`. Leaves `concurrent_futures_primes` (a verbatim stdlib baseline) and `integration/open_context_and_sleep` (its tractor nursery is commented out) as-is, and the paren-group `trio.open_nursery()` bindings unannotated (no clean spot for a preceding annotation). Completes the examples-typing bullet in #472. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codewkt/big_boi_docs_472_follow_ups
parent
069df08529
commit
56fbed0be1
|
|
@ -33,15 +33,16 @@ async def main() -> None:
|
||||||
rank = MPI.COMM_WORLD.Get_rank()
|
rank = MPI.COMM_WORLD.Get_rank()
|
||||||
print(f"[parent] rank={rank} pid={os.getpid()}", flush=True)
|
print(f"[parent] rank={rank} pid={os.getpid()}", flush=True)
|
||||||
|
|
||||||
|
an: tractor.ActorNursery
|
||||||
async with tractor.open_nursery(start_method='trio') as an:
|
async with tractor.open_nursery(start_method='trio') as an:
|
||||||
portal = await an.start_actor(
|
portal: tractor.Portal = await an.start_actor(
|
||||||
'mpi-child',
|
'mpi-child',
|
||||||
enable_modules=[child_fn.__module__],
|
enable_modules=[child_fn.__module__],
|
||||||
# Without this the child replays __main__, which
|
# Without this the child replays __main__, which
|
||||||
# re-imports mpi4py and crashes on MPI_Init.
|
# re-imports mpi4py and crashes on MPI_Init.
|
||||||
inherit_parent_main=False,
|
inherit_parent_main=False,
|
||||||
)
|
)
|
||||||
result = await portal.run(child_fn)
|
result: str = await portal.run(child_fn)
|
||||||
print(f"[parent] got: {result}", flush=True)
|
print(f"[parent] got: {result}", flush=True)
|
||||||
await portal.cancel_actor()
|
await portal.cancel_actor()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ async def acquire_singleton_lock(
|
||||||
|
|
||||||
|
|
||||||
async def hold_lock_forever(
|
async def hold_lock_forever(
|
||||||
task_status=trio.TASK_STATUS_IGNORED
|
task_status: trio.TaskStatus = trio.TASK_STATUS_IGNORED,
|
||||||
):
|
) -> None:
|
||||||
async with (
|
async with (
|
||||||
tractor.trionics.maybe_raise_from_masking_exc(),
|
tractor.trionics.maybe_raise_from_masking_exc(),
|
||||||
acquire_singleton_lock() as lock,
|
acquire_singleton_lock() as lock,
|
||||||
|
|
@ -46,7 +46,7 @@ async def main(
|
||||||
ignore_special_cases: bool,
|
ignore_special_cases: bool,
|
||||||
loglevel: str = 'info',
|
loglevel: str = 'info',
|
||||||
debug_mode: bool = True,
|
debug_mode: bool = True,
|
||||||
):
|
) -> None:
|
||||||
async with (
|
async with (
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ async def main(
|
||||||
|
|
||||||
raise_unmasked: bool = False,
|
raise_unmasked: bool = False,
|
||||||
loglevel: str = 'info',
|
loglevel: str = 'info',
|
||||||
):
|
) -> None:
|
||||||
tractor.log.get_console_log(level=loglevel)
|
tractor.log.get_console_log(level=loglevel)
|
||||||
|
|
||||||
# the `.aclose()` being checkpoints on these
|
# the `.aclose()` being checkpoints on these
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue