python - python gevent LoopExit:'此操作将永远阻塞'
问题描述
我正在使用 python 的 gevent 从烧瓶端点调用的多个 API url 获取数据。我的代码结构如下:
我有一个包含端点的视图文件。相应的视图函数调用一个包装文件。然后这个包装函数为所有可用的 url 生成所有 greenlet。包装函数的代码如下所示:
URL_MAP = {
'url-0001' : 'SpecificModule'
}
pool = []
for url_id, module in URL_MAP.iteritems():
# get_url_instance imports the module and creates an object of the class.
url_instance = get_url_instance(url_id)
if url_instance:
# spawn a greenlet
pool.append(gevent.spawn(url_instance.get_data))
gevent.joinall(pool)
但不幸的是,当我尝试通过 Postman 访问端点时,它会在服务器上引发以下错误:
LoopExit: ('This operation would block forever', <Hub at 0x7f506064eaf0 epoll pending=0 ref=0 fileno=4>)
关于我所缺少的任何线索?
解决方案
推荐阅读
- python - Pyton3:计算 SHA3 适用于笔记本电脑,但不适用于 Amazon EC2 服务器
- python - 属性错误模块“张量流”没有属性“__version__”,与“keras”类似
- java - 如何从 ListView 中获取选定项的值
- javascript - 如何在 React Native 中将图像添加到导航抽屉的标题?
- javascript - 如何像浏览器一样在 html 元素内部制作移动响应视图?
- javascript - 在 amcharts 的堆积柱形图中,如何在工具提示中显示特定列的所有值?
- c# - 我无法使用 system.linq.IQueryable 返回值,有什么办法吗?
- c++ - 在 MSVC 2017 中继承模板构造函数和错误 C2600
- python - 在 Python 中为矩阵赋值
- hibernate - Hibernate Jboss Tools 无法生成 hibernate.cfg.xml 文件