From 50bbfa36cff1db09cde083e23171a1ae3d8dabc2 Mon Sep 17 00:00:00 2001 From: korneel Date: Tue, 28 Feb 2023 14:18:43 +0100 Subject: [PATCH] fix for GCS Connection Error #606 (#686) https://cloud.google.com/python/docs/reference/storage/2.1.0/retry_timeout --- tensorboardX/record_writer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorboardX/record_writer.py b/tensorboardX/record_writer.py index a4b7b5a..250a7a3 100644 --- a/tensorboardX/record_writer.py +++ b/tensorboardX/record_writer.py @@ -149,7 +149,10 @@ def flush(self): upload_buffer = copy.copy(self.buffer) upload_buffer.seek(0) - self.blob.upload_from_string(upload_buffer.getvalue()) + # work with blob generation, so that uploading will automatically retry in case of connection errors + blob_generation = self.blob.generation + self.blob.upload_from_string(data=upload_buffer.getvalue(), + if_generation_match=blob_generation) def close(self): self.flush()