title: Python append to tarfile in parallel
body: <pre><code>import tarfile
  from cStringIO import StringIO
  from io import BytesIO as BIO
  
  unique_keys = ['1:bigstringhere...:5'] * 5000
  file_out = BytesIO()
  tar = tarfile.open(mode='w:bz2', fileobj=file_out)
  for k in unique_keys:
      id, mydata, s_index= k.split(':')
      inner_fname = '%s_%s.data' % (id, s_index)
      info = tarfile.TarInfo(inner_fname)
      info.size = len(mydata)
      tar.addfile(info, StringIO(mydata))
  tar.close()
  </code></pre>
  
  <p>I would like to do the above loop to add to the tarfile (tar) in parallel for faster execution.</p>
  
  <p>Any ideas?</p>