You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to write a long-running app with a Hangouts connection, so in the event of a disconnect I'd like to handle this quietly in the background. Currently I have something like the following:
client=hangups.Client(hangups.auth.get_auth_stdin("refresh_token.txt"))
loop=asyncio.get_event_loop()
defon_connect():
# Some other initialisation stuff here.passdefon_disconnect():
try:
loop.stop()
exceptRuntimeErrorase:
# Couldn't stop the event loop?passwhileloop.is_running():
time.sleep(1)
loop.run_until_complete(client.connect())
defrun():
client.on_connect.add_observer(on_connect)
client.on_reconnect.add_observer(on_connect)
client.on_disconnect.add_observer(on_disconnect)
try:
loop.run_until_complete(client.connect())
exceptExceptionase:
# Hangups exception?passon_disconnect()
But on the second connect() call inside on_disconnect, I get:
ValueError: <function on_connect at 0x6ffffffffff> is already an observer of Event('Channel.on_connect')
Trying to restart a stopped event loop also gives errors like:
RuntimeError: Event loop stopped before Future completed.
This all feels rather messy -- I haven't used asyncio before so I'm not entirely sure if there's a better way to work with the event loop. Is there a correct way to handle reconnects?
The text was updated successfully, but these errors were encountered:
I'm attempting to write a long-running app with a Hangouts connection, so in the event of a disconnect I'd like to handle this quietly in the background. Currently I have something like the following:
But on the second
connect()
call insideon_disconnect
, I get:Trying to restart a stopped event loop also gives errors like:
This all feels rather messy -- I haven't used
asyncio
before so I'm not entirely sure if there's a better way to work with the event loop. Is there a correct way to handle reconnects?The text was updated successfully, but these errors were encountered: