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()