[英]socketio use callback tips create_client.<locals>.test() missing 1 required positional argument: 'ack'
server code:服务器代码:
def test_call_back(text):
print(text)
sio.emit('test', 'test call back', callback=test_call_back)
cliend code:客户端代码:
@sio.on('test')
def test(data,ack):
print(data)
ack()
run wrong tips:运行错误提示:
create_client.<locals>.test() missing 1 required positional argument: 'ack'
How should I use callback?我应该如何使用回调?
You seem to be using the JavaScript client documentation and applying that to the Python client.您似乎正在使用 JavaScript 客户端文档并将其应用于 Python 客户端。 The Python client is not a clone, so please use the Python documentation instead.
Python 客户端不是克隆,因此请改用 Python 文档。 For callbacks: https://python-socketio.readthedocs.io/en/latest/client.html#event-callbacks .
对于回调: https://python-socketio.readthedocs.io/en/latest/client.html#event-callbacks 。
Example ack that returns two values to the other side:向另一方返回两个值的示例 ack:
@sio.event
def my_event(sid, data):
# handle the message
return "OK", 123
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.