python - Python eventlet 库:TypeError:'coroutine' 对象不可迭代
问题描述
我正在使用python socket io和eventlet库创建一个 wsgi 服务器。我正在使用 socket io 库来利用 web socket。这是我在服务器端的代码:
import eventlet
import eventlet.wsgi
import socketio
static_files = {
'/': './public/index.html',
'/public/style.css' : './public/style.css',
'/public/index.js' : './public/index.js',
}
sio = socketio.AsyncServer(cors_allowed_origins=['*'])
app = socketio.WSGIApp(sio, static_files=static_files)
eventlet.wsgi.server(eventlet.listen(('', 8080)), app)
在 js 代码中,我在浏览器上运行时通过 websocket 连接:
const socket = io("http://localhost:8080");
从浏览器连接到 localhost:8080 后出现错误;该网站已提供服务,但服务器崩溃并显示以下错误(“TypeError:'coroutine' object is not iterable”): 我该如何解决这个问题?
解决方案
推荐阅读
- java - 编写包含多个具有公共字段的枚举的类的最佳方法
- r - 用for循环创建矩阵
- javascript - node.js 中的 PayPal 字段和小数错误
- python - Python Tkinter 通过列表登录功能
- python - 如何在具有多个条件的多列 col0、col1、col2 上使用替换方法
- eclipse - Eclipse 上的 Google OR-Tools 7
- python - torchtext 库中的 interleave_keys() 函数究竟做了什么?
- java - 如何检测从我的应用程序启动的相机应用程序已移至后台?
- android - 如何获取 MaterialAlertDialog 当前背景颜色
- performance-testing - How to inject a constant number of users in Gatling?