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

Improve time management when retrieving services metadata #153

Merged
merged 2 commits into from
Aug 30, 2022
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
22 changes: 19 additions & 3 deletions pyluos/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def widgets(*args, **kwargs):

Event = namedtuple('Event', ('name', 'old_value', 'new_value'))

READ_TIMEOUT = 0.3

class Service(object):
possible_events = set()
Expand Down Expand Up @@ -84,20 +85,35 @@ def _push_data(self, key, new_val, data):

@property
def firmware_revision(self):
self._firmware_revision = None
self._push_value('revision', "")
time.sleep(0.03)

tick_start = time.time()
while time.time() - tick_start < READ_TIMEOUT and self._firmware_revision is None:
time.sleep(0.01)

return self._firmware_revision

@property
def luos_revision(self):
self._luos_revision = None
self._push_value('luos_revision', "")
time.sleep(0.03)

tick_start = time.time()
while time.time() - tick_start < READ_TIMEOUT and self._luos_revision is None:
time.sleep(0.01)

return self._luos_revision

@property
def uuid(self):
self._uuid = None
self._push_value('uuid', "")
time.sleep(0.03)

tick_start = time.time()
while time.time() - tick_start < READ_TIMEOUT and self._uuid is None:
time.sleep(0.01)

return self._uuid

@property
Expand Down