Fix recursion depth limit exception in DanceFloor

This commit is contained in:
Ben 2020-03-14 18:24:13 +00:00
parent 48f303dbdd
commit c02b6e164d

View File

@ -56,6 +56,11 @@ class DanceFloor:
self._dancers.pop(p.id)
await self.send_xt('zm', self.get_string())
async def start(self):
while True:
await self.next_round()
await asyncio.sleep(self._current_track.song_length_millis // 1000)
async def next_round(self):
self._current_track = self._queued_track
@ -84,9 +89,6 @@ class DanceFloor:
self._queued_track = next(self._tracks)
self._next_song_timestamp = int(round(time.time() * 1000)) + self._current_track.song_length_millis
await asyncio.sleep(self._current_track.song_length_millis // 1000)
await self.next_round()
async def send_xt(self, *data):
for dancer in self._dancers.values():
await dancer.penguin.send_xt(*data)
@ -147,7 +149,7 @@ async def songs_load(server):
server.logger.info(f'Loaded {len(server.dance_songs)} dance tracks')
server.dance_floor = DanceFloor(server)
asyncio.create_task(server.dance_floor.next_round())
asyncio.create_task(server.dance_floor.start())
@handlers.handler(XTPacket('gz', ext='z'))