@@ -3205,6 +3205,8 @@ static void *owngil_context_thread_main(void *arg) {
32053205
32063206 PyStatus status = Py_NewInterpreterFromConfig (& ctx -> own_gil_tstate , & config );
32073207 if (PyStatus_IsError (status )) {
3208+ fprintf (stderr , "OWN_GIL: Py_NewInterpreterFromConfig failed: %s\n" ,
3209+ status .err_msg ? status .err_msg : "unknown error" );
32083210 PyGILState_Release (gstate );
32093211 atomic_store (& ctx -> thread_running , false);
32103212 return NULL ;
@@ -3218,6 +3220,7 @@ static void *owngil_context_thread_main(void *arg) {
32183220
32193221 /* Register erlang module in this subinterpreter */
32203222 if (create_erlang_module () < 0 ) {
3223+ fprintf (stderr , "OWN_GIL: create_erlang_module failed\n" );
32213224 PyErr_Print ();
32223225 Py_EndInterpreter (ctx -> own_gil_tstate );
32233226 atomic_store (& ctx -> thread_running , false);
@@ -3226,6 +3229,7 @@ static void *owngil_context_thread_main(void *arg) {
32263229
32273230 /* Register py_event_loop module for reactor support */
32283231 if (create_py_event_loop_module () < 0 ) {
3232+ fprintf (stderr , "OWN_GIL: create_py_event_loop_module failed\n" );
32293233 PyErr_Print ();
32303234 Py_EndInterpreter (ctx -> own_gil_tstate );
32313235 atomic_store (& ctx -> thread_running , false);
@@ -3676,15 +3680,16 @@ static int owngil_context_init(py_context_t *ctx) {
36763680 return -1 ;
36773681 }
36783682
3679- /* Wait for thread to initialize */
3683+ /* Wait for thread to initialize - up to 5 seconds on slow CI */
36803684 int wait_count = 0 ;
3681- while (!atomic_load (& ctx -> thread_running ) && wait_count < 1000 ) {
3685+ while (!atomic_load (& ctx -> thread_running ) && wait_count < 5000 ) {
36823686 usleep (1000 ); /* 1ms */
36833687 wait_count ++ ;
36843688 }
36853689
36863690 if (!atomic_load (& ctx -> thread_running )) {
3687- /* Thread failed to start */
3691+ /* Thread failed to start - check if there's an init error */
3692+ fprintf (stderr , "OWN_GIL thread failed to initialize after %d ms\n" , wait_count );
36883693 pthread_join (ctx -> own_gil_thread , NULL );
36893694 enif_free_env (ctx -> shared_env );
36903695 pthread_cond_destroy (& ctx -> response_ready );
0 commit comments