2021-02-24 18:39:14 +00:00
|
|
|
import trio
|
2020-02-09 07:01:39 +00:00
|
|
|
import tractor
|
|
|
|
|
|
2026-08-29 22:58:43 +00:00
|
|
|
tractor.log.get_console_log('INFO')
|
2020-02-09 07:01:39 +00:00
|
|
|
|
2021-02-24 18:39:14 +00:00
|
|
|
|
Type the docs-visible `examples/` scripts
Type the runtime objects (`ActorNursery`, `Portal`, `Context`,
`trio.Nursery`) + fn signatures across the 16 highest-visibility,
`literalinclude`-d `examples/` scripts, matching the front-page
`we_are_processes.py` style — so the rendered guides show typed
usage throughout, not just on the landing snippet.
Spans the 3 quickstart-backing scripts + `single_func`,
`remote_error_propagation`, `multiple_streams_one_portal`,
`quick_cluster`, `service_discovery`, `service_daemon_discovery`,
`asynchronous_generators`, `nested_actor_tree`,
`concurrent_actors_primes`, `streaming_broadcast_fanout`,
`rpc_bidir_streaming`, `infected_asyncio_echo_server`,
`typed_payloads`.
Annotation-only (no renames/logic changes); each runs green and the
docs build stays warning-free. Part of 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-code
2026-07-02 16:32:49 +00:00
|
|
|
async def main(service_name: str) -> None:
|
2026-08-29 22:58:43 +00:00
|
|
|
'''
|
|
|
|
|
Discover one actor and inspect its registrar connection.
|
2020-02-09 07:01:39 +00:00
|
|
|
|
2026-08-29 22:58:43 +00:00
|
|
|
'''
|
Type the docs-visible `examples/` scripts
Type the runtime objects (`ActorNursery`, `Portal`, `Context`,
`trio.Nursery`) + fn signatures across the 16 highest-visibility,
`literalinclude`-d `examples/` scripts, matching the front-page
`we_are_processes.py` style — so the rendered guides show typed
usage throughout, not just on the landing snippet.
Spans the 3 quickstart-backing scripts + `single_func`,
`remote_error_propagation`, `multiple_streams_one_portal`,
`quick_cluster`, `service_discovery`, `service_daemon_discovery`,
`asynchronous_generators`, `nested_actor_tree`,
`concurrent_actors_primes`, `streaming_broadcast_fanout`,
`rpc_bidir_streaming`, `infected_asyncio_echo_server`,
`typed_payloads`.
Annotation-only (no renames/logic changes); each runs green and the
docs build stays warning-free. Part of 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-code
2026-07-02 16:32:49 +00:00
|
|
|
an: tractor.ActorNursery
|
2020-02-09 07:01:39 +00:00
|
|
|
async with tractor.open_nursery() as an:
|
|
|
|
|
await an.start_actor(service_name)
|
|
|
|
|
|
2026-08-29 22:58:43 +00:00
|
|
|
async with tractor.get_registry() as reg_portal:
|
|
|
|
|
print(
|
|
|
|
|
f'Registrar is listening on {reg_portal.channel}'
|
|
|
|
|
)
|
2020-02-09 07:01:39 +00:00
|
|
|
|
2026-08-29 22:58:43 +00:00
|
|
|
actor_portal: tractor.Portal
|
|
|
|
|
async with tractor.wait_for_actor(
|
|
|
|
|
service_name,
|
|
|
|
|
) as actor_portal:
|
2026-08-30 00:24:25 +00:00
|
|
|
service_addr = actor_portal.chan.raddr
|
|
|
|
|
print(f'my_service is found at {service_addr}')
|
2020-02-09 07:01:39 +00:00
|
|
|
|
|
|
|
|
await an.cancel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2021-02-24 18:39:14 +00:00
|
|
|
trio.run(main, 'some_actor_name')
|