Concurrent write to text files

Post Reply
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Concurrent write to text files

Post by ArielRauch »

Hi,

I want to document all the metadata of my flows to a structured text files in order to upload them later to a database. (I do not have the database module)



I plan to write a script which extracts the current values of the metadata of a specific dataset and "appends" them to a text file. From time to time this file is copied away in order to upload it (probably another switch script) and all consequent writes will be written to a new file.



My question is whether the "append to file" action might interfere with concurrent ones and if so if I have to configure the script serialized.





Thanks



Ariel
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Concurrent write to text files

Post by freddyp »

Setting the execution mode of the script to "Serialized" is a safe approach.



Alternatively you could put the opening of the file in a loop until the opening does not throw an exception. Do not use a while loop, but a for loop (with a reasonable number of iterations) to avoid an endless loop, and perhaps use s.sleep inside the loop too.



Freddy
Post Reply