I am creating a multiplayer online game, and am using socket io for the game server. Below is my server code
import socketioimport timefrom aiohttp import websio = socketio.AsyncServer(async_mode='aiohttp', cors_allowed_origins='*', async_handlers=True)app = web.Application()sio.attach(app)@sio.on('connect')def connect(sid, environ): print("connected: ", sid)@sio.on('disconnect')def disconnect(sid): print('disconnect ', sid)async def background_thread(): while True: print("here") sio.emit('message', {'data': 'Server generated event'}) time.sleep(5)if __name__ == '__main__': print ("Starting server") sio.start_background_task(background_thread) web.run_app(app, port=3000)But the problem is the above code starts up the server but the background task is not running, where am I going wrong?