From bc098e12db1156b4a56bff50bbb3b2db4ff9e8ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <amuoz@ed.ac.uk>
Date: Thu, 16 Jun 2022 13:21:26 +0100
Subject: [PATCH] add rudimentary reconnection attempt to tiler

---
 aliby/tile/tiler.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/aliby/tile/tiler.py b/aliby/tile/tiler.py
index 0ad6bc33..e7d159a2 100644
--- a/aliby/tile/tiler.py
+++ b/aliby/tile/tiler.py
@@ -229,14 +229,24 @@ class Tiler(ProcessABC):
     def get_tc(self, t, c):
         # Get image by forcing loading it into cache. Assumes TCZYX dimensional order.
         # WORKAROUND around error (which arose on 2022/06/14) when fetching 3-D data.
-        full = np.stack(
-            [
+        n_attempts = 0
+        while n_attempts < 5:
+
+            try:
+                full = np.stack(
+                    [
                 self.image[t, c, z].compute()
                 for z in range(self.image.shape[2])
-            ],
-            axis=0,
-        )
-        # full = self.image[t, c].compute()
+                    ],
+                    axis=0,
+                )
+                # full = self.image[t, c].compute()
+                n_attempts=5
+            except:
+                print("Warning: Error ocurred when fetching images. Attempt {}".format(n_attempts+1))
+                self.image.conn.connect()
+                n_attempts += 1
+
 
         return full
 
-- 
GitLab