hawkrobe / reference_games

Conventions in iterated reference games
8 stars 8 forks source link

Race-condition in data logging code (writeDataToCSV) #30

Open forkunited opened 6 years ago

forkunited commented 6 years ago

Sometimes, the first round of output for a game is not logged by writeDataToCSV. I'm under the impression that this is caused by the following:

At this line 62, writeDataToCSV calls establishStream (see https://github.com/hawkrobe/reference_games/blob/master/experiments/sharedUtils/sharedUtils.js#L62 )

establishStream calls writeFile to write the header of the csv asynchronously. Then, writeDataToCSV calls write on a stream to the same file. If the writeFile in establishStream does not finish before the write in writeDataToCSV, then the data from the write is lost.