Skip to content

[FFI][BUGFIX] Grab GIL when check env signals#17419

Merged
tqchen merged 1 commit intoapache:mainfrom
tqchen:py-signal
Sep 26, 2024
Merged

[FFI][BUGFIX] Grab GIL when check env signals#17419
tqchen merged 1 commit intoapache:mainfrom
tqchen:py-signal

Conversation

@tqchen
Copy link
Copy Markdown
Member

@tqchen tqchen commented Sep 25, 2024

This PR updates the CheckSignals function to grab GIL. This is needed because we now explicitly release gil when calling any C functions. GIL will need to be obtained otherwise we will run into segfault when checking the signal.

The update now enables us to run ctrl + C in long running C functions.

@tqchen
Copy link
Copy Markdown
Member Author

tqchen commented Sep 25, 2024

run the following code and press control + C to check if signal is intercepted in python

import numpy as np
import tvm


def main():
    print("start")
    tvm.get_global_func("testing.check_signals")(0.01)
    print("good")

main()

This PR updates the CheckSignals function to grab GIL.
This is needed because we now explicitly release gil when calling
any C functions. GIL will need to be obtained otherwise we will
run into segfault when checking the signal.

The update now enables us to run ctrl + C in long running C functions.
@MasterJH5574
Copy link
Copy Markdown
Contributor

@tvm-bot rerun

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