remove special TqdmThreadPoolExecutor logic

- fixes #2686
- closes #2703
This commit is contained in:
Casper da Costa-Luis
2019-11-02 15:22:46 +00:00
parent 306c916626
commit 82dae6c25b
+2 -23
View File
@@ -2,34 +2,13 @@
from __future__ import print_function
import logging
import sys
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
from funcy import merge
from dvc.utils import env2bool
logger = logging.getLogger(__name__)
class TqdmThreadPoolExecutor(ThreadPoolExecutor):
"""
Ensure worker progressbars are cleared away properly.
"""
def __enter__(self):
"""
Creates a blank initial dummy progress bar if needed so that workers
are forced to create "nested" bars.
"""
blank_bar = Tqdm(bar_format="", leave=False)
if blank_bar.pos > 0:
# already nested - don't need a placeholder bar
blank_bar.close()
self.bar = blank_bar
return super(TqdmThreadPoolExecutor, self).__enter__()
def __exit__(self, *a, **k):
super(TqdmThreadPoolExecutor, self).__exit__(*a, **k)
self.bar.close()
TqdmThreadPoolExecutor = ThreadPoolExecutor
class Tqdm(tqdm):