Skip to content

Commit

Permalink
fix for GCS Connection Error #606 (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
korneelvdbroek committed Feb 28, 2023
1 parent ceabb20 commit 50bbfa3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorboardX/record_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 50bbfa3

Please sign in to comment.