Skip to content
Snippets Groups Projects
Commit 705dda8d authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Only wait 3 seconds for disconnect when refreshing

parent 553705b1
No related branches found
No related tags found
No related merge requests found
...@@ -257,18 +257,25 @@ class User(BaseUser): ...@@ -257,18 +257,25 @@ class User(BaseUser):
event_id = None event_id = None
self._is_refreshing = True self._is_refreshing = True
if self.listener: if self.listener:
self.log.debug("Disconnecting MQTT connection for session refresh...")
if self.temp_disconnect_notices or force_notice: if self.temp_disconnect_notices or force_notice:
event_id = await self.send_bridge_notice("Disconnecting Messenger MQTT connection " event_id = await self.send_bridge_notice("Disconnecting Messenger MQTT connection "
"for session refresh...") "for session refresh...")
self.listener.disconnect() self.listener.disconnect()
if self.listen_task: if self.listen_task:
await self.listen_task try:
await asyncio.wait_for(self.listen_task, timeout=3)
except asyncio.TimeoutError:
self.log.debug("Waiting for MQTT connection timed out")
else:
self.log.debug("MQTT connection disconnected")
self.listener = None self.listener = None
if self.client: if self.client:
self.client.sequence_id_callback = None self.client.sequence_id_callback = None
if self.temp_disconnect_notices or force_notice: if self.temp_disconnect_notices or force_notice:
event_id = await self.send_bridge_notice("Refreshing session...", edit=event_id) event_id = await self.send_bridge_notice("Refreshing session...", edit=event_id)
try: try:
self.log.debug("Re-loading session for refresh")
ok = await self.load_session(_override=True, _raise_errors=True) ok = await self.load_session(_override=True, _raise_errors=True)
except fbchat.FacebookError as e: except fbchat.FacebookError as e:
await self.send_bridge_notice("Failed to refresh Messenger session: " await self.send_bridge_notice("Failed to refresh Messenger session: "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment