pylibraft.common.interruptible

pylibraft.common.interruptible#

2 min read time

Applies to Linux

Functions#

cuda_interruptible(*args, **kwds)

cuda_interruptible()

cuda_yield()

cuda_yield()

synchronize(stream)

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.

pylibraft.common.interruptible.synchronize(stream: Stream)#

synchronize(Stream stream: Stream)

Same as cudaStreamSynchronize, but can be interrupted if called within a with cuda_interruptible() block.