Skip to content

Commit 0d7092d

Browse files
committed
fixes
1 parent 20c3736 commit 0d7092d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

runware/base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ async def _retry_with_reconnect(self, func, *args, **kwargs):
142142

143143
except Exception as e:
144144
last_error = e
145-
error_msg = str(e)
146145

147-
if "Invalid API key" not in error_msg:
146+
147+
if not isinstance(e, ConnectionError):
148148
raise
149149

150+
error_msg = str(e)
151+
150152
if attempt >= max_total_attempts - 1:
151153
self.logger.error(f"Max authentication retry attempts ({max_total_attempts}) exceeded")
152154
raise ConnectionError(
@@ -170,12 +172,23 @@ async def _retry_with_reconnect(self, func, *args, **kwargs):
170172
self._connectionSessionUUID = None
171173

172174
await self.connect()
175+
176+
177+
if not self.connected():
178+
raise ConnectionError("Reconnection failed; WebSocket is not open")
179+
173180
self.logger.info("Reconnection successful, retrying request")
174181

175182
except Exception as reconnect_error:
176183
self.logger.error(f"Error while reconnecting:", exc_info=reconnect_error)
177184
delay = self._reconnection_manager.calculate_delay()
178185
await asyncio.sleep(delay)
186+
187+
188+
raise ConnectionError(
189+
f"Retry loop in _retry_with_reconnect completed without success. "
190+
f"Last error: {last_error}"
191+
)
179192

180193
def _create_safe_async_listener(self, async_func):
181194
def wrapper(m):

0 commit comments

Comments
 (0)