Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-9610 - reconnect loop should exit if it fails #814

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/viam/robot/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import sys
from dataclasses import dataclass
from datetime import datetime
from threading import RLock
Expand Down Expand Up @@ -431,6 +432,9 @@ async def _check_connection(self, check_every: int, reconnect_every: int):
self._sessions_client.reset()
self._close_channel()
await asyncio.sleep(reconnect_every)
if not self._connected:
# We failed to reconnect, sys.exit() so that this thread doesn't stick around forever.
sys.exit()
Comment on lines +435 to +437
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that it will exit if it fails to reconnect once? I remember I did some work a few years ago that had to do with supporting reconnect attempts, so wanted to make sure this was something separate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have since expanded the code above this. 😅 LGTM!


def get_component(self, name: ResourceName) -> ComponentBase:
"""Get a component using its ResourceName.
Expand Down
Loading