我在使用concurrent.futures时,在我的streamlit应用程序中控制台收到了许多警告。
其中一些警告如下:
2020-10-28 15:43:59.338 Thread 'ThreadPoolExecutor-1_11': missing ReportContext
2020-10-28 15:43:59.338 Thread 'ThreadPoolExecutor-1_8': missing ReportContext
2020-10-28 15:43:59.339 Thread 'ThreadPoolExecutor-1_9': missing ReportContext
2020-10-28 15:43:59.339 Thread 'ThreadPoolExecutor-1_6': missing ReportContext
2020-10-28 15:43:59.339 Thread 'ThreadPoolExecutor-1_7': missing ReportContext
2020-10-28 15:43:59.340 Thread 'ThreadPoolExecutor-1_10': missing ReportContext
2020-10-28 15:43:59.340 Thread 'ThreadPoolExecutor-1_11': missing ReportContext
2020-10-28 15:43:59.341 Thread 'ThreadPoolExecutor-1_8': missing ReportContext
2020-10-28 15:43:59.341 Thread 'ThreadPoolExecutor-1_9': missing ReportContext
2020-10-28 15:43:59.342 Thread 'ThreadPoolExecutor-1_10': missing ReportContext
2020-10-28 15:43:59.342 Thread 'ThreadPoolExecutor-1_11': missing ReportContext
我知道应该使用 add_report_ctx(thread) 来创建线程。(参考链接)
我想知道如何在 concurrent.futures 中使用?
以下是我的部分代码:
def thread_run(func, values):
with ThreadPoolExecutor(max_workers=60) as executor:
futures = [executor.submit(func, value) for value in values]
for future in as_completed(futures):
yield future.result()