From c69f5a2d592aec944cc8ff6c4e59dce96428f359 Mon Sep 17 00:00:00 2001
From: Berk Onat <b.onat@warwick.ac.uk>
Date: Mon, 22 Jan 2018 17:04:31 +0000
Subject: [PATCH] json.dump fails for python3 with Broken Pipe Error for IO
 buffer due to . Trying to fix it with stdout.flush().

---
 common/python/nomadcore/parser_backend.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/python/nomadcore/parser_backend.py b/common/python/nomadcore/parser_backend.py
index f9e1b38..0108b74 100644
--- a/common/python/nomadcore/parser_backend.py
+++ b/common/python/nomadcore/parser_backend.py
@@ -97,6 +97,8 @@ class JsonParseEventsWriterBackend(object):
             self.fileOut.write(", ")
         else:
             self.__writeComma = True
+        self.fileOut.flush() # Python3 uses buffer for IO operations. 
+        # Need to flush the buffer before accessing the content at json.dump
         json.dump(dic, self.fileOut, indent = 2, separators = (',', ':'), sort_keys=True) # default = self.__numpyEncoder)
 
     def startedParsingSession(self, mainFileUri, parserInfo, parserStatus = None, parserErrors = None):
-- 
GitLab