🩹(backend) invert operation order in participant handling
Invert operation sequence to first notify people in room before setting participant in cache. Fixes infinite loop issue caused by 3s cache timeout for waiting participants when requests take too long. Problem only occurred when notifications were delayed, as faster notification delivery masked the race condition.
This commit is contained in:
committed by
aleb_the_flash
parent
b5b99d4c52
commit
18f4a117ab
@@ -221,6 +221,12 @@ class LobbyService:
|
||||
color=color,
|
||||
)
|
||||
|
||||
try:
|
||||
self.notify_participants(room_id=room_id)
|
||||
except LobbyNotificationError:
|
||||
# If room not created yet, there is no participants to notify
|
||||
pass
|
||||
|
||||
cache_key = self._get_cache_key(room_id, participant_id)
|
||||
cache.set(
|
||||
cache_key,
|
||||
@@ -228,12 +234,6 @@ class LobbyService:
|
||||
timeout=settings.LOBBY_WAITING_TIMEOUT,
|
||||
)
|
||||
|
||||
try:
|
||||
self.notify_participants(room_id=room_id)
|
||||
except LobbyNotificationError:
|
||||
# If room not created yet, there is no participants to notify
|
||||
pass
|
||||
|
||||
return participant
|
||||
|
||||
def _get_participant(
|
||||
|
||||
Reference in New Issue
Block a user