From c02b6e164db2fa048b8aed2238bfb19ae5461cce Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 14 Mar 2020 18:24:13 +0000 Subject: [PATCH] Fix recursion depth limit exception in DanceFloor --- houdini/handlers/games/dance.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/houdini/handlers/games/dance.py b/houdini/handlers/games/dance.py index faaecbe..70945da 100644 --- a/houdini/handlers/games/dance.py +++ b/houdini/handlers/games/dance.py @@ -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'))