From fe0fd1a1c12634d8b1fad38e6d0ea5ff383e2ab4 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 17 Feb 2022 11:53:54 -0500 Subject: [PATCH] Add example that triggers bug #302 --- examples/open_context_and_sleep.py | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/open_context_and_sleep.py diff --git a/examples/open_context_and_sleep.py b/examples/open_context_and_sleep.py new file mode 100644 index 0000000..4c2db3e --- /dev/null +++ b/examples/open_context_and_sleep.py @@ -0,0 +1,49 @@ +import trio +import click +import tractor +import pydantic +# from multiprocessing import shared_memory + + +@tractor.context +async def just_sleep( + + ctx: tractor.Context, + **kwargs, + +) -> None: + ''' + Test a small ping-pong 2-way streaming server. + + ''' + await ctx.started() + await trio.sleep_forever() + + +async def main() -> None: + + proc = await trio.open_process( ( + 'python', + '-c', + 'import trio; trio.run(trio.sleep_forever)', + )) + await proc.wait() + # await trio.sleep_forever() + # async with tractor.open_nursery() as n: + + # portal = await n.start_actor( + # 'rpc_server', + # enable_modules=[__name__], + # ) + + # async with portal.open_context( + # just_sleep, # taken from pytest parameterization + # ) as (ctx, sent): + # await trio.sleep_forever() + + + +if __name__ == '__main__': + import time + # time.sleep(999) + trio.run(main)