MCPcopy Create free account
hub / github.com/tensorflow/datasets / _async_tqdm

Function _async_tqdm

tensorflow_datasets/core/utils/tqdm_utils.py:150–172  ·  view source on GitHub ↗

Wrapper around Tqdm which can be updated in threads. Usage: ``` with utils.async_tqdm(...) as pbar: # pbar can then be modified inside a thread # pbar.update_total(3) # pbar.update() ``` Args: *args: args of tqdm **kwargs: kwargs of tqdm Yields: pbar: Async pb

(*args, **kwargs)

Source from the content-addressed store, hash-verified

148
149@contextlib.contextmanager
150def _async_tqdm(*args, **kwargs):
151 """Wrapper around Tqdm which can be updated in threads.
152
153 Usage:
154
155 ```
156 with utils.async_tqdm(...) as pbar:
157 # pbar can then be modified inside a thread
158 # pbar.update_total(3)
159 # pbar.update()
160 ```
161
162 Args:
163 *args: args of tqdm
164 **kwargs: kwargs of tqdm
165
166 Yields:
167 pbar: Async pbar which can be shared between threads.
168 """
169 with tqdm_lib.tqdm(*args, **kwargs) as pbar:
170 pbar = _TqdmPbarAsync(pbar)
171 yield pbar
172 pbar.clear() # pop pbar from the active list of pbar
173
174
175class _TqdmPbarAsync(EmptyTqdm):

Callers 1

async_tqdmFunction · 0.85

Calls 3

_TqdmPbarAsyncClass · 0.85
clearMethod · 0.80
tqdmMethod · 0.45

Tested by

no test coverage detected