'python socketio ow to push tasks regularly?

How to push tasks regularly? i try it like this but client tips packet queue is empty, aborting

sio = socketio.Server(cors_allowed_origins="*")
app = socketio.WSGIApp(sio, static_files={'/': {'content_type': 'text/html', 'filename': 'index.html'}})

def check_wait_reply():
    sio.emit('message', 123123)
    keyer = Timer(10, check_wait_reply)
    keyer.start()


if __name__ == '__main__':
    check_wait_reply()
    eventlet.wsgi.server(eventlet.listen(('', 3000)), app)


Solution 1:[1]

I had the same problem and found the answer thanks to Miguel's comment.

Here's the working solution:

sio = socketio.Server(cors_allowed_origins="*")
app = socketio.WSGIApp(sio, static_files={'/': {'content_type': 'text/html', 'filename': 'index.html'}})

def check_wait_reply():
    while True:
        sio.sleep(10)
        sio.emit('message', 123123)


if __name__ == '__main__':
    sio.start_background_task(check_wait_reply)
    eventlet.wsgi.server(eventlet.listen(('', 3000)), app)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian Metzger-Noel