Open mnmelo opened 3 years ago
Hi! Maybe similar to you, I have another hack way to "squeeze out" tqdm ProgressBar. Differently,it will conbined with Analysis class in Pool. It will be applied in a customized AnalysisMethod which you might designed.
class AnalysisMethod(AnalysisBase):
def run(start,step,stop,verbose=False):
# a weird print to "squezze out" tqdm based ProgressBar
if verbose == True:
print(" ", end='')
When using
multiprocessing
for parallelization with Jupyter, having a forked child run an analysis (or a chunk thereof) and print the progress bar fails to show the bar (nothing is shown but execution does progress in parallel).The server console complains once per iteration that
[IPKernelApp] WARNING | WARNING: attempted to send message from fork
plus the actual JSON progress bar update message.This has been reported for other, cases. The latter link provides a workaround that solves it for me: to make the child(ren) that do the progress bar outputting print and flush something (can be a blank space) immediately upon initialization. This is simplest accomplished using an initializer function to
multiprocess.Pool
:There is possibly a less hackish solution if some
ProgressBar
internals are reworked. The links I post mention the use oftqdm.contrib.concurrent
(which seems to wrap around parallelization). AllowingAnalysisBase
to passkwargs
to the ProgressBar initialization (requested in #3190) may also offer other ways around this.