title: handling async streaming request in grpc python
body: <p>I am trying to understand how to handle a grpc api with bidirectional streaming (using the Python API).</p>
  
  <p>Say I have the following simple server definition:</p>
  
  <pre><code>syntax = "proto3";
  package simple;
  
  service TestService {
    rpc Translate(stream Msg) returns (stream Msg){}
  }
  
  message Msg
  {
   string msg = 1;
  }
  </code></pre>
  
  <p>Say that the messages that will be sent from the client come asynchronously ( as a consequence of user selecting some ui elements).</p>
  
  <p>The generated python stub for the client will contain a method <code>Translate</code> that will accept a generator function and will return an iterator.</p>
  
  <p>What is not clear to me is how would I write the generator function that will return messages as they are created by the user. Sleeping on the thread while waiting for messages doesn't sound like the best solution.</p>