In Faiss, slow functions periodically call InterruptCallback::check()
https://github.com/facebookresearch/faiss/blob/main/faiss/impl/AuxIndexStructures.h#L152
The callback is arbitrary. It does nothing by default.
In python there is an InterruptCallback that checks if the user pressed Ctrl-C.
It would be useful to implement an InterruptCallback that breaks out of a function that lasts too long, eg. a clustering.