add some retry logic to the verification initialization
This commit is contained in:
+12
-3
@@ -905,6 +905,11 @@ class CommunityBot(Plugin):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Create DM room with name
|
# Create DM room with name
|
||||||
|
max_retries = 3
|
||||||
|
retry_delay = 1 # seconds
|
||||||
|
last_error = None
|
||||||
|
|
||||||
|
for attempt in range(max_retries):
|
||||||
try:
|
try:
|
||||||
dm_room = await self.client.create_room(
|
dm_room = await self.client.create_room(
|
||||||
preset=RoomCreatePreset.PRIVATE,
|
preset=RoomCreatePreset.PRIVATE,
|
||||||
@@ -918,10 +923,14 @@ class CommunityBot(Plugin):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.log.info(f"Created DM room {dm_room} for {evt.sender}")
|
self.log.info(f"Created DM room {dm_room} for {evt.sender}")
|
||||||
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Failed to initiate verification process: {e}")
|
last_error = e
|
||||||
|
if attempt < max_retries - 1: # Don't sleep on the last attempt
|
||||||
|
self.log.warning(f"Failed to create DM room (attempt {attempt + 1}/{max_retries}): {e}")
|
||||||
|
await asyncio.sleep(retry_delay)
|
||||||
|
else:
|
||||||
|
self.log.error(f"Failed to initiate verification process after {max_retries} attempts: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Select random verification phrase
|
# Select random verification phrase
|
||||||
|
|||||||
Reference in New Issue
Block a user