pylibraft.common.interruptible#
2 min read time
Applies to Linux
Functions#
|
cuda_interruptible() |
cuda_yield() |
|
|
synchronize(Stream stream: Stream) |
Module Contents#
- pylibraft.common.interruptible.cuda_interruptible(*args, **kwds)#
cuda_interruptible()
Temporarily install a keyboard interrupt handler (Ctrl+C) that cancels the enclosed interruptible C++ thread.
Use this on a long-running C++ function imported via cython:
>>> with cuda_interruptible(): >>> my_long_running_function(...)
It’s also recommended to release the GIL during the call, to make sure the handler has a chance to run:
>>> with cuda_interruptible(): >>> with nogil: >>> my_long_running_function(...)
- pylibraft.common.interruptible.cuda_yield()#
cuda_yield()
Check for an asynchronously received interrupted_exception. Raises the exception if a user pressed Ctrl+C within a with cuda_interruptible() block before.