如何解决如何在不中断进度条的情况下进行打印?
我正在使用dask分布式来运行许多任务,其中一些打印一些状态输出。这些打印中断进度条,看起来很丑。
最小示例:
from time import sleep
from dask.distributed import Client,progress
def slow_func(n):
sleep(n)
if n % 2:
print('this print interrupts the progress bar')
def run():
client = Client()
futures = client.map(slow_func,range(5))
progress(*futures)
if __name__ == '__main__':
run()
输出:
[####### ] | 19% Completed | 0.9sthis print interrupts the progress bar
[######################## ] | 60% Completed | 2.9sthis print interrupts the progress bar
所需:
this print did not interrupt the progress bar
this print did not interrupt the progress bar
[######################## ] | 60% Completed | 2.9s
有什么办法吗?
解决方法
有什么办法吗?
据我所知,不。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。