首页 > 解决方案 > 使用工作类 gevent 运行 gunicorn 时,Python Bigquery to_dataframe 函数被阻止

问题描述

当我在 gunicorn 上使用 worker-class=gevent 运行烧瓶应用程序时,服务器会阻塞。

query = '...'
query_job = bigquery_client.query(query)\
query_job.to_dataframe()# to_dataframe function where block occurs
try:
    frame = worker_queue.get(timeout=_PROGRESS_INTERVAL) # this point
    yield frame

当工人阶级是一个小事件时,也会发生同样的情况。当 worker-class 是 gthread 或 sync 时不会发生。_pandas_helpers.py 中的块是按如下语法执行的,是不是线程相关的问题?

with concurrent.futures.ThreadPoolExecutor(max_workers=total_streams) as pool:

为什么会发生阻塞?

标签: pythongoogle-bigquerygunicorngeventeventlet

解决方案


推荐阅读