python - 使用工作类 gevent 运行 gunicorn 时,Python Bigquery to_dataframe 函数被阻止
问题描述
当我在 gunicorn 上使用 worker-class=gevent 运行烧瓶应用程序时,服务器会阻塞。
gunicorn 命令 gunicorn app:app --workers=5 --worker-class=gevent --threads=5 --timeout=1800 --log-level=DEBUG
源代码
query = '...'
query_job = bigquery_client.query(query)\
query_job.to_dataframe()# to_dataframe function where block occurs
- bigquery 库中出现块的源代码(google/cloud/bigquery/_pandas_helpers.py 文件的第 678 到 680 行)
try:
frame = worker_queue.get(timeout=_PROGRESS_INTERVAL) # this point
yield frame
- Python 库版本
- 蟒蛇=3.7.10
- 独角兽=20.1.0
- gevnet=21.1.2
- 小事件=0.30.2
- 谷歌云大查询=2.20.0
- 谷歌云大查询存储=2.4.0
- 谷歌云核心=1.6.0
- pyarrow=4.0.0
当工人阶级是一个小事件时,也会发生同样的情况。当 worker-class 是 gthread 或 sync 时不会发生。_pandas_helpers.py 中的块是按如下语法执行的,是不是线程相关的问题?
with concurrent.futures.ThreadPoolExecutor(max_workers=total_streams) as pool:
为什么会发生阻塞?
解决方案
推荐阅读
- c++ - insertElement() 函数无法按预期工作
- ios - 尽管在代码和属性检查器中设置了 UITextfield.Text 颜色,但它不起作用 - Swift/Xcode
- javascript - 从javascript casperjs中的DOM元素中提取文本
- python - 理解具有并发期货的概念以加速网络抓取
- gerrit - gerrit 设置项目访问权限添加单个用户无效
- enums - typedef 的 System Verilog typedef
- mysql - 我如何检查我的 Db.Query 是否返回空行
- node.js - 如何让 Axios 使用 FormData 发送请求?
- python - 使用可修改符号进行比较(python)
- shell - 当我们使用 Shell 脚本 AIX Unix 添加用户时,如何验证 sudoers 中的某些用户?