MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / buffer_iterator

Function buffer_iterator

monai/data/thread_buffer.py:83–101  ·  view source on GitHub ↗

Create a ThreadBuffer object using the `src`, `buffer_size`, and `timeout` parameters given for the constructor arguments of the same names, and yield each generated object `repeats` number of times successively. Args: src: Source data iterable buffer_size: Number of it

(src, buffer_size: int = 1, timeout: float = 0.01, repeats: int = 1)

Source from the content-addressed store, hash-verified

81
82
83def buffer_iterator(src, buffer_size: int = 1, timeout: float = 0.01, repeats: int = 1):
84 """
85 Create a ThreadBuffer object using the `src`, `buffer_size`, and `timeout` parameters given for the constructor
86 arguments of the same names, and yield each generated object `repeats` number of times successively.
87
88 Args:
89 src: Source data iterable
90 buffer_size: Number of items to buffer from the source
91 timeout: Time to wait for an item from the buffer, or to wait while the buffer is full when adding items
92 repeats: Number of repeat generations to perform which is asynchronous from the generation of the next value
93
94 Returns:
95 Generator yield (repeated) values from `src` asynchronously
96 """
97 buffer = ThreadBuffer(src=src, buffer_size=buffer_size, timeout=timeout)
98
99 for batch in buffer:
100 for _ in range(repeats):
101 yield batch
102
103
104class _ProcessThread(Thread):

Callers 1

__iter__Method · 0.85

Calls 1

ThreadBufferClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…