Writing to one file from several streams in ruby

I am trying to write to a single file from multiple streams. The problem I am facing is that I do not see anything being written to the file before the program exits.

+6
ruby file-io
source share
2 answers

You need file.flush to write it. You can also set file.sync = true to enable it automatically.

+5
source share

What is the value of the synchronization method for your io object? It is possible that either ruby ​​or basic o / s buffer the output of the file.

Check out the buffering and synchronization guidelines in the documentation.

0
source share

All Articles