Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing to a single file from multiple threads in ruby

Tags:

file-io

ruby

I am trying to write to a single file from multiple threads. The problem I'm running into is that I don't see anything being written to the file until the program exits.

like image 507
AdamB Avatar asked May 03 '10 22:05

AdamB


1 Answers

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

like image 137
Peter Avatar answered Nov 15 '22 05:11

Peter