问题
使用 eventlet 0.25.0 和 python-socketio 4.0.3 w/ Python 3.7,我试图让两个 Python 脚本与 websocket 进行通信。服务器脚本运行良好:
import socketio # type: ignore
import eventlet
import json
import util as u # type: ignore
eventlet.monkey_patch()
WSGI_LOG_FORMAT = '%(client_ip)s "%(request_line)s" %(status_code)s %(body_length)s %(wall_seconds).6f'
class DatabaseServer:
""" Initializes a server using socketio and eventlet. Use start() and stop() to... start and stop it.
push() pushes new data to all clients
"""
def __init__(self):
self.server = socketio.Server(async_mode='eventlet', namespace='/socket.io')
self.server.on('connect', self.connect, namespace='/socket.io')
self.server.on('disconnect', self.disconnect, namespace='/socket.io')
self.server.on('client_response', self.client_response, namespace='/socket.io') …Run Code Online (Sandbox Code Playgroud)