0

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?

IFCZT
  • 89
  • 8

1 Answers1

0

You seem to be using the JavaScript client documentation and applying that to the Python client. The Python client is not a clone, so please use the Python documentation instead. For callbacks: https://python-socketio.readthedocs.io/en/latest/client.html#event-callbacks.

Example ack that returns two values to the other side:

@sio.event
def my_event(sid, data):
    # handle the message
    return "OK", 123
Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152