|
42 | 42 | mixed_waiter_async_blocks_sync_test/1, |
43 | 43 | %% Async receive with actual waiting |
44 | 44 | async_receive_wait_e2e_test/1, |
45 | | - %% Subinterpreter mode tests |
46 | | - subinterp_sync_receive_wait_test/1, |
47 | 45 | %% Close and drain tests |
48 | 46 | close_drain_erlang_test/1, |
49 | 47 | close_drain_python_sync_test/1, |
@@ -80,8 +78,6 @@ all() -> [ |
80 | 78 | mixed_waiter_async_blocks_sync_test, |
81 | 79 | %% Async receive with actual waiting |
82 | 80 | async_receive_wait_e2e_test, |
83 | | - %% Subinterpreter mode tests |
84 | | - subinterp_sync_receive_wait_test, |
85 | 81 | %% Close and drain tests |
86 | 82 | close_drain_erlang_test, |
87 | 83 | close_drain_python_sync_test, |
@@ -551,71 +547,6 @@ async def receive_from_channel(ch_ref): |
551 | 547 |
|
552 | 548 | ok = py_channel:close(Ch). |
553 | 549 |
|
554 | | -%%% ============================================================================ |
555 | | -%%% Subinterpreter Mode Tests |
556 | | -%%% ============================================================================ |
557 | | - |
558 | | -%% @doc Test sync blocking receive works with subinterpreter mode contexts |
559 | | -%% This is a true e2e test: Python Channel.receive() blocks until Erlang sends data |
560 | | -subinterp_sync_receive_wait_test(_Config) -> |
561 | | - case py_nif:subinterp_supported() of |
562 | | - false -> |
563 | | - {skip, "Subinterpreters not supported (requires Python 3.12+)"}; |
564 | | - true -> |
565 | | - do_subinterp_sync_receive_wait_test() |
566 | | - end. |
567 | | - |
568 | | -do_subinterp_sync_receive_wait_test() -> |
569 | | - {ok, Ch} = py_channel:new(), |
570 | | - Self = self(), |
571 | | - |
572 | | - %% Create a context explicitly in subinterp mode |
573 | | - CtxId = erlang:unique_integer([positive]), |
574 | | - {ok, CtxPid} = py_context:start_link(CtxId, subinterp), |
575 | | - |
576 | | - %% Import Channel class in the subinterp context |
577 | | - ok = py_context:exec(CtxPid, <<"from erlang import Channel">>), |
578 | | - |
579 | | - %% Test 1: Immediate receive with data already available |
580 | | - ok = py_channel:send(Ch, <<"immediate_data">>), |
581 | | - {ok, <<"immediate_data">>} = py_context:eval(CtxPid, |
582 | | - <<"Channel(ch).receive()">>, #{<<"ch">> => Ch}), |
583 | | - ct:pal("Subinterp immediate receive OK"), |
584 | | - |
585 | | - %% Test 2: Blocking receive - spawn process to send data after delay |
586 | | - spawn_link(fun() -> |
587 | | - timer:sleep(100), |
588 | | - ok = py_channel:send(Ch, <<"delayed_data">>), |
589 | | - Self ! data_sent |
590 | | - end), |
591 | | - |
592 | | - %% This should block until the spawned process sends data |
593 | | - {ok, <<"delayed_data">>} = py_context:eval(CtxPid, |
594 | | - <<"Channel(ch).receive()">>, #{<<"ch">> => Ch}), |
595 | | - receive data_sent -> ok after 1000 -> ok end, |
596 | | - ct:pal("Subinterp blocking receive OK"), |
597 | | - |
598 | | - %% Test 3: try_receive on empty channel returns None |
599 | | - {ok, none} = py_context:eval(CtxPid, |
600 | | - <<"Channel(ch).try_receive()">>, #{<<"ch">> => Ch}), |
601 | | - ct:pal("Subinterp try_receive empty OK"), |
602 | | - |
603 | | - %% Test 4: Channel close detected by receive |
604 | | - ok = py_channel:close(Ch), |
605 | | - ok = py_context:exec(CtxPid, <<" |
606 | | -def test_closed(ch_ref): |
607 | | - try: |
608 | | - Channel(ch_ref).receive() |
609 | | - return 'no_exception' |
610 | | - except: |
611 | | - return 'got_exception' |
612 | | -">>), |
613 | | - {ok, <<"got_exception">>} = py_context:eval(CtxPid, |
614 | | - <<"test_closed(ch)">>, #{<<"ch">> => Ch}), |
615 | | - ct:pal("Subinterp closed channel detected OK"), |
616 | | - |
617 | | - py_context:stop(CtxPid). |
618 | | - |
619 | 550 | %%% ============================================================================ |
620 | 551 | %%% Close and Drain Tests |
621 | 552 | %%% ============================================================================ |
|
0 commit comments