Skip to content

Commit 2a75703

Browse files
committed
refactor: raise directly from except instead of tracking last_error
Eliminates the Optional[SfuJoinError] variable and TYPE_CHECKING assert by raising from the except block when retries are exhausted.
1 parent 33d18b9 commit 2a75703

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

getstream/video/rtc/connection_manager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,16 +462,16 @@ def _on_coordinator_task_done(task: asyncio.Task):
462462
async def _connect_with_sfu_reassignment(self) -> None:
463463
"""Try connecting to SFU, reassigning to a different one on failure."""
464464
failed_sfus: list[str] = []
465-
last_error: Optional[SfuJoinError] = None
466465

467466
# First attempt without delay
468467
attempt = 0
469468
try:
470469
await self._connect_internal()
471470
return
472471
except SfuJoinError as e:
473-
last_error = e
474472
self._handle_join_failure(e, attempt, failed_sfus)
473+
if self._max_join_retries == 0:
474+
raise
475475

476476
# Retries with exponential backoff, requesting a different SFU
477477
async for delay in exp_backoff(max_retries=self._max_join_retries, base=0.5):
@@ -484,10 +484,9 @@ async def _connect_with_sfu_reassignment(self) -> None:
484484
)
485485
return
486486
except SfuJoinError as e:
487-
last_error = e
488487
self._handle_join_failure(e, attempt, failed_sfus)
489-
490-
raise last_error # type: ignore[misc]
488+
if attempt >= self._max_join_retries:
489+
raise
491490

492491
def _handle_join_failure(
493492
self, error: SfuJoinError, attempt: int, failed_sfus: list[str]

0 commit comments

Comments
 (0)