title: gRPC slow communication together with pyGTK
body: <p>I am using pyGTK and a python gRPC server. Both in a very basic setup.</p>
  
  <p>I just create a <code>gtk.Window()</code>, <code>show()</code> it and run a <code>gtk.main()</code> loop.</p>
  
  <p>My server starts like that:</p>
  
  <pre><code>def startServing():
      global server
      print("Starting server...")
      server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
      laserClient_pb2_grpc.add_LComServicer_to_server(LCom(), server)
      server.add_insecure_port('[::]:50053') # [::] is the same as 0.0.0.0    server.start()
      print("Server is running...")
  </code></pre>
  
  <p>So I call:</p>
  
  <pre><code>try:
      startServing()
      gtk.main()
  except KeyboardInterrupt:
      server.stop(0)
  </code></pre>
  
  <p>This creates the window correctly but I never receive a request from my Java client. (The java client is not the problem.)</p>
  
  <p>I read a lot on the internet and I do not understand all of the pyGTK thread handling but I tried <code>gtk.gdk.threads_init()</code> right before <code>startServing()</code> and I received the requests. However I receive just 1 request per second whereas my client sends a request every 50ms. If I delete <code>gtk.main()</code> and add a while loop:</p>
  
  <pre><code>while True:
      time.sleep(60)
  </code></pre>
  
  <p><strong>...I receive requests nearly every 50 to 100ms. This is the expected behaviour!</strong></p>
  
  <p>However my window won't get updated since there is no <code>gtk.main()</code> loop anymore. I even tried adding:</p>
  
  <pre><code>while True:
      while gtk.events_pending():
          gtk.main_iteration()
      time.sleep(0.05)
  </code></pre>
  
  <p>But this gives, again, just 1 request per second.</p>
  
  <p>I have no idea what I should do now. I really want to use gRPC and pyGTK together in the same program.</p>