1 async def main():
2 async with websockets.connect(websocket_address) as websocket:
3 while 1:
4 try:
5 a = readValues() #read values from a function
6 insertdata(a) #function to write values to mysql
7 await websocket.send("some token to recognize that it's the db socket")
8 time.sleep(20) #wait and then do it again
9 except Exception as e:
10 print(e)
11
12asyncio.get_event_loop().run_until_complete(main())
13