INNER CODE UNIT · Python
_check_activity
briscverse/ryp · ryp.py:1496
def _check_activity(select: _cffi_backend._CDataBase,
timeout=0.1) -> _cffi_backend._CDataBase:
"""
A reimplementation of R's R_checkActivity() that avoids the longjmp in
R_SelectEx(), which causes it to segfault when run on a background thread.
Checks for activity on each of the file descriptors in R_InputHandlers,
such as a plot being resized or closed. Not used on Windows.
Args:
select: a pointer to the select function in the C standard library
timeout: the timeout in seconds, passed to the select() system call
Returns:
A mask of file descriptors that are waiting to be handled, or NULL if
none are waiting.
"""
NFDBITS = 8 * _ffi.sizeof('unsigned long')
read_mask = _ffi.new('fd_set *') # initialized to 0, so skip FD_ZERO()