Add section about Python::check_signals to the FAQ

This commit is contained in:
Patrick Chieppe 2020-11-30 11:38:40 +11:00
parent 0696f03807
commit bba1cf19b3

View file

@ -27,3 +27,9 @@ version = "*"
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
```
## Ctrl-C doesn't do anything while my Rust code is executing!
This is because Ctrl-C raises a SIGINT signal, which is handled by the calling Python process by simply setting a flag to action upon later. This flag isn't checked while Rust code called from Python is executing, only once control returns to the Python interpreter.
You can give the Python interpreter a chance to process the signal properly by calling `Python::check_signals`. It's good practice to call this function regularly if you have a long-running Rust function so that your users can cancel it.