@@ -30,9 +30,6 @@ init_per_suite(Config) ->
3030 {ok , _ } = application :ensure_all_started (erlang_python ),
3131 % % Ensure contexts are running
3232 {ok , _ } = py :start_contexts (),
33- % % Install Erlang event loop policy for asyncio.run()
34- Ctx = py :context (1 ),
35- ok = py :exec (Ctx , <<" import erlang; erlang.install()" >>),
3633 Config .
3734
3835end_per_suite (_Config ) ->
@@ -55,13 +52,14 @@ test_asyncio_sleep(_Config) ->
5552 ok = py :exec (Ctx , <<"
5653import asyncio
5754import time
55+ import erlang
5856
5957async def timed_sleep():
6058 start = time.monotonic()
6159 await asyncio.sleep(0.05)
6260 return time.monotonic() - start
6361
64- elapsed = asyncio .run(timed_sleep())
62+ elapsed = erlang .run(timed_sleep())
6563assert elapsed >= 0.04, f'Expected >= 0.04s, got {elapsed:.3f}s'
6664" >>),
6765 ok .
@@ -72,6 +70,7 @@ test_asyncio_gather(_Config) ->
7270 ok = py :exec (Ctx , <<"
7371import asyncio
7472import time
73+ import erlang
7574
7675async def task(val):
7776 await asyncio.sleep(0.05)
@@ -85,7 +84,7 @@ async def main():
8584 # Allow more time on CI (0.3s instead of 0.15s)
8685 assert elapsed < 0.3, f'Expected < 0.3s, got {elapsed:.3f}s'
8786
88- asyncio .run(main())
87+ erlang .run(main())
8988" >>),
9089 ok .
9190
@@ -94,6 +93,7 @@ test_asyncio_tcp_echo(_Config) ->
9493 Ctx = py :context (1 ),
9594 ok = py :exec (Ctx , <<"
9695import asyncio
96+ import erlang
9797
9898async def handler(r, w):
9999 data = await r.read(100)
@@ -115,7 +115,7 @@ async def test():
115115 await srv.wait_closed()
116116 assert resp == b'hello', f'Expected b\" hello\" , got {resp}'
117117
118- asyncio .run(test())
118+ erlang .run(test())
119119" >>),
120120 ok .
121121
@@ -124,6 +124,7 @@ test_asyncio_concurrent_tcp(_Config) ->
124124 Ctx = py :context (1 ),
125125 ok = py :exec (Ctx , <<"
126126import asyncio
127+ import erlang
127128
128129async def handler(r, w):
129130 data = await r.read(100)
@@ -153,6 +154,6 @@ async def test():
153154 await srv.wait_closed()
154155 assert set(results) == {b're:1', b're:2', b're:3'}, f'Expected {{b\" re:1\" , b\" re:2\" , b\" re:3\" }}, got {set(results)}'
155156
156- asyncio .run(test())
157+ erlang .run(test())
157158" >>),
158159 ok .
0 commit comments