Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 25, 2025
1 parent 919a5f7 commit a28b944
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ jobs:
fail-fast: false
matrix:
include:
# - pair: { elixir: "1.18.1", otp: "27.2" }
# python_minor: "10"
- pair: { elixir: "1.15.8", otp: "25.3" }
python_minor: "10"
- pair: { elixir: "1.18.1", otp: "27.2" }
python_minor: "13"
# - pair: { elixir: "1.18.1", otp: "27.2" }
# python_minor: "13"
env:
MIX_ENV: test
PYTHONX_TEST_PYTHON_MINOR: ${{ matrix.python_minor }}
Expand Down
16 changes: 8 additions & 8 deletions c_src/pythonx/pythonx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,29 @@ class PyGILGuard {
PyThreadStatePtr state;

{
std::cout << "wait thread_states_mutex" << std::endl;
std::cout << "wait thread_states_mutex " << this->thread_id << std::endl;
auto guard = std::lock_guard<std::mutex>(thread_states_mutex);
std::cout << "got thread_states_mutex" << std::endl;
std::cout << "got thread_states_mutex " << this->thread_id << std::endl;

if (thread_states.find(this->thread_id) == thread_states.end()) {
// Note that PyThreadState_New does not require GIL to be held.
std::cout << "before PyThreadState_New" << std::endl;
std::cout << "before PyThreadState_New " << this->thread_id << std::endl;
state = PyThreadState_New(interpreter_state);
std::cout << "after PyThreadState_New" << std::endl;
std::cout << "after PyThreadState_New " << this->thread_id << std::endl;
} else {
state = thread_states[this->thread_id];
}
}

std::cout << "wait PyEval_RestoreThread" << std::endl;
std::cout << "wait PyEval_RestoreThread " << this->thread_id << std::endl;
PyEval_RestoreThread(state);
std::cout << "got PyEval_RestoreThread" << std::endl;
std::cout << "got PyEval_RestoreThread " << this->thread_id << std::endl;
}

~PyGILGuard() {
std::cout << "before PyEval_SaveThread" << std::endl;
std::cout << "before PyEval_SaveThread " << this->thread_id << std::endl;
PyEval_SaveThread();
std::cout << "after PyEval_SaveThread" << std::endl;
std::cout << "after PyEval_SaveThread " << this->thread_id << std::endl;
}
};

Expand Down

0 comments on commit a28b944

Please sign in to comment.