-
-
Notifications
You must be signed in to change notification settings - Fork 579
Closed
Description
I'm running websocket client in my MacOS. Everything is OK after running.
Then I shutdown the wifi connection for 10 seconds, and re-connect to wifi .
I found that my application is dead....
So, How to exit the loop event - run_forever() in my own function? thanks.
class WSS():
WSS.wss_uri= 'wss://...'
async def wss_main():
async with websockets.connect(WSS.wss_uri) as ws:
async for message in ws:
print(message)
# If the network has some issue , I want to quit this loop. How to ?
def wss_run():
running = False
while True:
if not running:
try:
running = True
wss = WSS()
asyncio.get_event_loop().run_until_complete(wss.wss_main())
asyncio.get_event_loop().run_forever()
except Exception as e:
print(e)
running = False
time.sleep(1)
wss_run()Metadata
Metadata
Assignees
Labels
No labels