nvflare.fuel.f3.streaming.stream_utils module

class CheckedExecutor(max_workers=None, thread_name_prefix='')[source]

Bases: ThreadPoolExecutor

This executor ignores task after shutting down

Initializes a new ThreadPoolExecutor instance.

Parameters:
  • max_workers – The maximum number of threads that can be used to execute the given calls.

  • thread_name_prefix – An optional name prefix to give our threads.

  • initializer – A callable used to initialize worker threads.

  • initargs – A tuple of arguments to pass to the initializer.

shutdown(wait=True)[source]

Clean-up the resources associated with the Executor.

It is safe to call this method several times. Otherwise, no other methods can be called after this one.

Parameters:
  • wait – If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed.

  • cancel_futures – If True then shutdown will cancel all pending futures. Futures that are completed or running will not be cancelled.

submit(fn, *args, **kwargs)[source]

Submits a callable to be executed with the given arguments.

Schedules the callable to be executed as fn(*args, **kwargs) and returns a Future instance representing the execution of the callable.

Returns:

A Future representing the given call.

class FastBuffer(buf: bytes | bytearray | memoryview | list | None = None)[source]

Bases: object

A buffer with fast appending

append(buf: bytes | bytearray | memoryview | list)[source]

Fast append by doubling the size of the buffer when it runs out

to_bytes() bytes | bytearray | memoryview | list[source]

Return bytes-like object. Once this method is called, append() may not work any longer, since the buffer may have been exported

gen_stream_id() int[source]
stream_shutdown()[source]
stream_stats_category(fqcn: str, channel: str, topic: str, stream_type: str = 'byte')[source]
wrap_view(buffer: bytes | bytearray | memoryview | list) memoryview[source]