Skip to content

Commit 3b2fa26

Browse files
committed
Increase OWN_GIL init timeout to 5s and add error logging
1 parent 8f5a15c commit 3b2fa26

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ jobs:
7373
rebar3 compile
7474
7575
- name: Run tests
76-
run: |
77-
rebar3 ct --suite=py_asyncio_compat_SUITE --case=test_base_erlang --verbose || true
78-
cat _build/test/logs/last/*/suite.log 2>/dev/null || true
79-
rebar3 ct --readable=compact
76+
run: rebar3 ct --readable=compact
8077

8178
- name: Run dialyzer
8279
run: rebar3 dialyzer

c_src/py_nif.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)