Skip to content

Commit e27680b

Browse files
committed
Add example that triggers bug #302
1 parent f000764 commit e27680b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

examples/open_context_and_sleep.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import trio
2+
import click
3+
import tractor
4+
import pydantic
5+
# from multiprocessing import shared_memory
6+
7+
8+
@tractor.context
9+
async def just_sleep(
10+
11+
ctx: tractor.Context,
12+
**kwargs,
13+
14+
) -> None:
15+
'''
16+
Test a small ping-pong 2-way streaming server.
17+
18+
'''
19+
await ctx.started()
20+
await trio.sleep_forever()
21+
22+
23+
async def main() -> None:
24+
25+
proc = await trio.open_process( (
26+
'python',
27+
'-c',
28+
'import trio; trio.run(trio.sleep_forever)',
29+
))
30+
await proc.wait()
31+
# await trio.sleep_forever()
32+
# async with tractor.open_nursery() as n:
33+
34+
# portal = await n.start_actor(
35+
# 'rpc_server',
36+
# enable_modules=[__name__],
37+
# )
38+
39+
# async with portal.open_context(
40+
# just_sleep, # taken from pytest parameterization
41+
# ) as (ctx, sent):
42+
# await trio.sleep_forever()
43+
44+
45+
46+
if __name__ == '__main__':
47+
import time
48+
# time.sleep(999)
49+
trio.run(main)

0 commit comments

Comments
 (0)