From d6f86921a98106a137818ece6e4271c787f832ec Mon Sep 17 00:00:00 2001 From: pyrokine Date: Sun, 3 Apr 2022 21:04:56 -0400 Subject: [PATCH] handle get board failure --- main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c6ae5524..4b267944 100755 --- a/main.py +++ b/main.py @@ -480,7 +480,6 @@ def get_unset_pixel(self, x, y, index): x = 0 if y >= self.image_size[1]: - y = 0 if x == originalX and y == originalY and loopedOnce: @@ -493,7 +492,16 @@ def get_unset_pixel(self, x, y, index): imgOutdated = True if imgOutdated: - boardimg = self.get_board(self.access_tokens[index]) + while True: + try: + boardimg = self.get_board(self.access_tokens[index]) + break + except Exception as e: + logger.info( + "Thread #{} : Get board image failed, trying again in 10 seconds... ", + index, + ) + time.sleep(10) pix2 = boardimg.convert("RGB").load() imgOutdated = False @@ -530,6 +538,7 @@ def get_unset_pixel(self, x, y, index): x + self.pixel_x_start, y + self.pixel_y_start, ) + x += 1 loopedOnce = True return x, y, new_rgb