mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
In the event of too many channel users, fail gracefully by reusing a random channel instead of always the previous one.
This commit is contained in:
parent
91a9a9b88f
commit
b6449a7056
@ -405,15 +405,19 @@ class RadioRegistry:
|
|||||||
already allocated.
|
already allocated.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
while_count = 0
|
||||||
while (channel := random_frequency(radio)) in self.allocated_channels:
|
while (channel := random_frequency(radio)) in self.allocated_channels:
|
||||||
|
while_count += 1
|
||||||
|
if while_count > 1000:
|
||||||
|
raise StopIteration
|
||||||
pass
|
pass
|
||||||
self.reserve(channel)
|
self.reserve(channel)
|
||||||
return channel
|
return channel
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
# In the event of too many channel users, fail gracefully by reusing
|
# In the event of too many channel users, fail gracefully by reusing
|
||||||
# the last channel.
|
# a channel.
|
||||||
# https://github.com/dcs-liberation/dcs_liberation/issues/598
|
# https://github.com/dcs-liberation/dcs_liberation/issues/598
|
||||||
channel = radio.last_channel
|
channel = random_frequency(radio)
|
||||||
logging.warning(
|
logging.warning(
|
||||||
f"No more free channels for {radio.name}. Reusing {channel}."
|
f"No more free channels for {radio.name}. Reusing {channel}."
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user