Agent: Lock RelayUserHandler.has_*_users()

This commit is contained in:
Mike Salvatore 2022-09-07 00:02:23 -04:00
parent 90dcb0a91e
commit e2736a9273
1 changed files with 10 additions and 8 deletions

View File

@ -76,18 +76,20 @@ class RelayUserHandler:
"""
Return whether or not we have any potential users.
"""
self._potential_users = dict(
filter(lambda ru: not ru[1].timer.is_expired(), self._potential_users.items())
)
with self._lock:
self._potential_users = dict(
filter(lambda ru: not ru[1].timer.is_expired(), self._potential_users.items())
)
return len(self._potential_users) > 0
return len(self._potential_users) > 0
def has_connected_users(self) -> bool:
"""
Return whether or not we have any relay users.
"""
self._relay_users = dict(
filter(lambda ru: not ru[1].timer.is_expired(), self._relay_users.items())
)
with self._lock:
self._relay_users = dict(
filter(lambda ru: not ru[1].timer.is_expired(), self._relay_users.items())
)
return len(self._relay_users) > 0
return len(self._relay_users) > 0