Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Var::toDouble() and start-up with named import module #3

Closed
wants to merge 1 commit into from
Closed

Conversation

dhoegerlETM
Copy link

Please review my proposed fixes - at least the toDouble() and the missing calls to PyEval_SaveThread()

@reefactor
Copy link
Owner

reefactor commented Apr 27, 2024

Many Thanks for reporting the bug, I've fixed this obvious toDouble() converter bug,
in recent please check out #4

But there's another important issue with your PR: it unlocks GIL in main thread with PyEval_SaveThread() which causes CI tests pipeline to crash with Segmentation fault obviously because of unlocked GIL.
For scoped GIL management there's ScopedGILRelease and GILLocker for scoped unlocking

We can discuss GIL management patterns.

@dhoegerlETM
Copy link
Author

Thanks for fixing the other points! What's about the forward declaration of "PyExceptionData" (inconsistency of class/struct).

Concerning the additional call to PyEval_SaveThread() => I examined a crash when executing Python code in a separate thread and found this discussion with the proposed fix on the internet:
https://stackoverflow.com/questions/10625584/embedding-python-in-multithreaded-c-application

Maybe you know a better way to avoid blocking the Python execution engine? Is there some trigger to the even-loop similar to Node.js v8 engine? I'd really love to avoid an extra thread for Python-eval.

@reefactor
Copy link
Owner

Yes fixed PyExceptionData
and added autotest example how to work with GIL in #5

I assume you need to add cppy3::ScopedGILRelease gilRelease code blocks in your threads

We can dig on details If you can provide more description on your use case.
Best way is to submit a failing testcase code

@dhoegerlETM dhoegerlETM closed this May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants