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)
| 81 | |
| 82 | |
| 83 | def 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 | |
| 104 | class _ProcessThread(Thread): |
no test coverage detected
searching dependent graphs…