Commits

Anonymous committed 24ebfd0

Reopen closed files correctly using append mode
Update the self.bucket_files dict when files reopen

  • Participants
  • Parent commits f05cbdb

Comments (0)

Files changed (1)

File pyf/splitter/inputsplitter.py

         """Close all existing bucket files
         """
         for data_file in self.bucket_files.values():
+            
             if not data_file.closed:
                 data_file.close()
 
             else:
                 bucket_file = self.bucket_files[bucket_filename]
                 if not bucket_file.closed:
+                    # close the bucket file because -> to many open files
                     bucket_file.close()
 
         # no enough space available
 
         file_obj = self.bucket_files[bucket_filename]
 
+        tobeclosed = False
         if file_obj.closed:
-            file_obj = open(bucket_filename, 'wb')
+            tobeclosed = True
+            file_obj = open(bucket_filename, 'ab')
+            self.bucket_files[bucket_filename] = file_obj
 
         self.store_input_item(file_obj, input_item_str)
+        if tobeclosed:
+            file_obj.close()
 
     def __get_reference_value(self, input_item):
         """Retrieve the reference value for the item item