I am trying to create a single progress bar that will be updated whenever an async task is done.
I have the following code
scan_results = []
tasks = [self.run_scan(i) for i in input_paths]
pbar = tqdm(total=len(tasks), desc='Scanning files')
for f in asyncio.as_completed(tasks):
value = await f
pbar.update(1)
scan_results.append(value)
The above code generates a single progress bar as but it is not updated until all tasks are finished (it shows either 0% or 100% while there's more than a single task)
I also tried using tqdm.asyncio.tqdm.gather
with tqdm(total=len(input_paths)):
scan_results = await tqdm.gather(*[self.run_scan(i) for i in input_paths])
The above code generates multiple progress bars and as in the previous code block, it shows either 0% or 100%
My starting point was
scan_results = await asyncio.gather(*[self.run_scan(i)for i in input_paths])
Would appreciate your help on making it work with a single and dynamic progress bar