Skip to content

Ensure GIL during C callbacks - #505

Merged
CGraczyk merged 1 commit into
scipopt:masterfrom
AntoinePrv:ensure-gil
Jun 30, 2021
Merged

CGraczyk merged 1 commit into
scipopt:masterfrom
AntoinePrv:ensure-gil

Conversation

@AntoinePrv

Copy link
Copy Markdown
Contributor

During all C callbacks ensure that the GIL is held before executing Python code.

In Ecole we don't hold the GIL when calling SCIPsolve, so if users have added a callback through Python, user would get

Fatal Python error: PyThreadState_Get: no current thread

This is a prerequisite to #430 , but I think it we should do a bit more testing before actually removing the GIL in intensive methods.

@gasse

gasse commented Jun 29, 2021

Copy link
Copy Markdown
Contributor

I've had segfaults when using Ecole + an event handler registered through PySCIPOpt, which this PR seems to fix. Any reason it hasn't been merged yet ?

Related discussion about this issue here:
ds4dm/ecole#193

@CGraczyk

Copy link
Copy Markdown
Contributor

@mattmilten do you have some insight here?

@mattmilten

mattmilten commented Jun 29, 2021 •

Copy link
Copy Markdown
Collaborator

I guess we can merge this. I don't see an issue and the tests pass ¯\_(ツ)_/¯

@gasse

gasse commented Jun 29, 2021

Copy link
Copy Markdown
Contributor

Awesome. It seems safe indeed. And it would greatly improve the Ecole + PySCIPOpt compatibility :)

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.

4 participants