You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great library! I'm not sure whether this is something you've already looked into/tried or if this would be a new feature addition.
Anyhow, I have a script I am running using p_tqdm and I'd like to achieve something similar to tqdm.write where you can have the progress bar fixed to the bottom whilst printed messages to stdout end up above that. The script is rather large and rather than manually going in and changing those print statements I've borrowed a SO answer to overload print.
A simple repro script is as follows:
importtimeimportinspectfromp_tqdmimportp_mapfromp_tqdm.p_tqdmimporttqdm# NOTE: here I've also tried importing tqdm as `from tqdm.auto import tqdm`.. no luckdefdivert_stdout_to_tqdm() ->None:
old_print=printdefnew_print(*args, **kwargs) ->None:
# if tqdm.tqdm.write raises error, use builtin printtry:
tqdm.write(*args, **kwargs)
except:
old_print(*args, **kwargs)
inspect.builtins.print=new_printdefdo_stuff(num: int) ->None:
print("HIIIIII")
time.sleep(0.5)
divert_stdout_to_tqdm()
# doesn't workresults=p_map(do_stuff, range(100))
# worksforiintqdm(range(100)):
do_stuff(i)
results=p_map(do_stuff, range(100))
doesn't work exactly as I'd intend as it produces output as such:
Great library! I'm not sure whether this is something you've already looked into/tried or if this would be a new feature addition.
Anyhow, I have a script I am running using
p_tqdm
and I'd like to achieve something similar totqdm.write
where you can have the progress bar fixed to the bottom whilst printed messages to stdout end up above that. The script is rather large and rather than manually going in and changing thoseprint
statements I've borrowed a SO answer to overloadprint
.A simple repro script is as follows:
doesn't work exactly as I'd intend as it produces output as such:
works as intended and produces output as such:
I am also not an expert in the
multiprocessing
library and it is very well possible that this is more related tomultiprocessing
than it isp_tqdm
.The text was updated successfully, but these errors were encountered: