title: Boto3: Wait for S3 streaming upload to complete
body: <p><strong>I'm using <code>S3.Client.upload_fileobj()</code> with a <code>BytesIO</code> stream as input to upload a file to S3 from a stream. My function should not return before the upload is finished, so I need a way to wait it.</strong></p>
  
  <p>From the documentation there is no obvious way to wait for the transfer to finish, but there are some hints of what <em>could</em> work:</p>
  
  <ol>
  <li>Use the <strong>callback arg</strong> to wait until progress is at 100%. In Javascript this would be trivial using callbacks or promises, but in Python I'm not so sure.</li>
  <li>Use a <strong><code>S3.Waiter</code> object</strong> that checks if the object exists. But it does so by polling every 5s and seems very ineffective. Also I'm not sure if it would wait until the object is complete.</li>
  <li>There's a class <strong><code>S3.MultipartUpload</code></strong> with a <code>.complete()</code> method, but I doubt that does what I want.</li>
  <li>Do a <strong>loop</strong> that checks if the object is completely uploaded and if not, sleeps for a bit. But how do I check if the object is complete?</li>
  </ol>
  
  <p>I've been googling but it seems nobody is asking the same question. Also, most results talking about related issues are using a different API (I believe <code>upload_fileobj()</code> is rather new).</p>
  
  <p><strong>EDIT</strong>
  If found out about <a href="http://boto3.readthedocs.io/en/latest/reference/services/s3.html#S3.Client.put_object" rel="noreferrer"><strong><code>S3.Client.put_object</code></strong></a> which also accepts a file-like object and blocks until the server responded. But would that work in combination with streams? I'm not sure how Python multithreading works here. The stream comes originally from a <code>S3.Client.download_fileobj()</code>, gets piped through a <code>subprocess.Popen()</code> and is then supposed to get uploaded back to S3. Both the download and the subprocess run in parallel threads/processes as fas as I can tell.</p>