title: Atomic write to multiple files
body: <p>Suppose I have a set of files. How do I ensure that writing to <strong>all</strong> these files is atomic.</p>
  
  <p>I thought about writing to temp files and only after the writing is successful, perform an atomic rename of each file. However renaming all the files at once isn't atomic. Also this will not scale to very large files if we'd like to append to these files.</p>
  
  <p>Instead I thought about implementing transactions but then that's becoming a project on its own. I realize that this is pretty much about implementing a mini database.</p>
  
  <p>How would you do it in Python?</p>
  
  <pre><code>d = FileWriter.open(['file1', 'file2'], 'wb+')
  d.write('add hello world to files')
  d.close()
  </code></pre>
  
  <p>Ensure that d.write is atomic or at least rollback to original files if unsuccessful.</p>