控制python多线程未完成

问题描述

我正在尝试抓取多个Internet数据,并且为此目的使用了 concurrent.futures 。 在此过程中,似乎部分功能评估尚未完成

    # Récupération histo du fonds
df = pd.DataFrame()

with tqdm(total=len(urls),desc='Historique des fonds',leave=True,position=0) as pbar:
    # let's give it some more threads:
    with ThreadPoolExecutor() as executor:
        futures = {executor.submit(get_histo_table,url): url for url in urls}
        for future in as_completed(futures):
            try:
                data = future.result(timeout=0.001)
            except:
                print('probleme get_histo')
                pass
            else:
                df = pd.concat([df,data]).reset_index(drop=True)
            pbar.update(1)
return df

screen output

在执行某些代码python的过程中,如果没有错误消息,则无法完成该过程。

是否可以强制 concurrent.futures 退出此不可用的过程并完成我的所有计算? 我必须完成它,当它被阻止时,我停止了jupyterlab,然后重新启动了我的程序,并且(有时)它运行良好...直到下一个程序。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)