title: Asynchronous execution of Python subprocess.Popen with wait()
body: <p>I'm new to Python async concepts. However I want to sequentially call 2 functions, the order is what matters here:</p>
  <pre class="lang-py prettyprint-override"><code>def func1():
      p = subprocess.Popen('ffmpeg -i in.webm out.mp4')
      p.wait()
  
  def func2():
      os.remove('in.webm')
  
  func1()
  func2()
  </code></pre>
  <p>Function 1 contains subprocess which converts video files, and function 2 deletes the input afterwards.<br />
  <code>Popen</code> with <code>p.wait()</code> does force synchronous execution but it comes at the price of blocking the main thread.<br />
  <code>Popen</code> without <code>p.wait()</code> doesn't block it but makes function 2 to get called before ffmpeg will complete its job.</p>
  <p>I would like to achieve something similar to Javascript promises or async/await constructs like this:</p>
  <pre class="lang-js prettyprint-override"><code>async func1() {
      let response = await fetch('/api');
      let user = await response.json();
      return user;
  }
  
  func2(func1());
  </code></pre>
  <p>Sounds like a trivial task but I'm lost between multithreading, multiprocessing and asyncio.<br />
  How can I make function 2 to await for the output of function 1 without blocking the main thread?</p>