Skip to main content

iterate_file_descriptors_safely

Apply hub method to fds in iter, remove from list if failure.

def iterate_file_descriptors_safely(
fds_iter: iterable,
source_data: list|set|dict,
hub_method: callable,
*args: any,
**kwargs: any
) - > null

Apply hub method to fds in iter, remove from list if failure. Some file descriptors may become stale through OS reasons or possibly other reasons, so safely manage our lists of FDs.

Parameters

NameTypeDescription
fds_iteriterableThe collection of file descriptors to iterate over and process using the hub_method.
source_data`listset
hub_methodcallableThe function or method to execute for each file descriptor in the iteration.
*argsanyPositional arguments passed to the hub_method; the string 'fd' acts as a placeholder that is replaced by the current file descriptor object during execution.
**kwargsanyKeyword arguments passed directly to the hub_method without substitution.

Returns

TypeDescription
nullThis function does not return a value; it modifies the source_data collection in-place.