Skip to content

Commit f6853a6

Browse files
committed
Register py_event_loop module in OWN_GIL subinterpreters
Fix reactor tests failing in OWN_GIL mode by registering the py_event_loop module during OWN_GIL thread initialization. The reactor functions call get_module_state() to access the reactor cache, which requires the py_event_loop module to exist. Without this, get_module_state() returns NULL and reactor operations fail. Enable the previously skipped py_reactor_context tests now that OWN_GIL reactor dispatch works correctly.
1 parent 0851392 commit f6853a6

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

c_src/py_nif.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,14 @@ static void *owngil_context_thread_main(void *arg) {
28242824
return NULL;
28252825
}
28262826

2827+
/* Register py_event_loop module for reactor support */
2828+
if (create_py_event_loop_module() < 0) {
2829+
PyErr_Print();
2830+
Py_EndInterpreter(ctx->own_gil_tstate);
2831+
atomic_store(&ctx->thread_running, false);
2832+
return NULL;
2833+
}
2834+
28272835
/* Create namespace dictionaries */
28282836
ctx->globals = PyDict_New();
28292837
ctx->locals = PyDict_New();

test/py_owngil_features_SUITE.erl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,6 @@ reactor.set_protocol_factory(EchoProtocol)
947947

948948
%% @doc Multiple connections in owngil reactor
949949
owngil_reactor_multiple_conn_test(_Config) ->
950-
{skip, "py_reactor_context OWN_GIL integration needs investigation"}.
951-
952-
owngil_reactor_multiple_conn_test_DISABLED(_Config) ->
953950
SetupCode = <<"
954951
import erlang.reactor as reactor
955952
@@ -1011,9 +1008,6 @@ reactor.set_protocol_factory(CounterProtocol)
10111008

10121009
%% @doc async_pending pattern in owngil reactor
10131010
owngil_reactor_async_pending_test(_Config) ->
1014-
{skip, "py_reactor_context OWN_GIL integration needs investigation"}.
1015-
1016-
owngil_reactor_async_pending_test_DISABLED(_Config) ->
10171011
SetupCode = <<"
10181012
import erlang.reactor as reactor
10191013
@@ -1079,9 +1073,6 @@ result = {
10791073

10801074
%% @doc Protocol factory isolation between owngil contexts
10811075
owngil_reactor_isolation_test(_Config) ->
1082-
{skip, "py_reactor_context OWN_GIL integration needs investigation"}.
1083-
1084-
owngil_reactor_isolation_test_DISABLED(_Config) ->
10851076
EchoSetup = <<"
10861077
import erlang.reactor as reactor
10871078

0 commit comments

Comments
 (0)