0

I would like to know if there is a recommended way to return data back from a server to a client in GRPC python.

Currently, I have a dedicated server's RPC call that blocks on every client call - it loops on a data queue(which blocks when empty) to get the data and sends it back to the client. The server implementation of this call:

    def GetData(self, request, context):
        while self._is_initialized:
            data = self._processed_data_queue.get()
            yield data 
        print 'client out'

It seems super awkward, non-scalable, and obviously slows down the communication. In NodeJS, C#, c++ implementations, it is much much easier to accomplish this. But with Python implementation it doesn't seem to be possible to accomplish this efficiently. I really hope I'm missing something.

In addition, the server currently accepts data from a client, add it to a queue and then return it back to the client(without any processing). Again, with the code above, my performance drops dramatically even without any processing!

Thanks, Mike

Mikev
  • 2,012
  • 1
  • 15
  • 27
Mike
  • 13
  • 2
  • 6
  • How does NodeJS, C#, or C++ implementations look different? – maged Oct 23 '18 at 19:13
  • It allows you to send out data from different context, while gRPC python doesn't. You have to block up the caller thread which is super awkward. Generally, the gRPC python seems less stable and not properly engineered compared to the other implementation. One can argue that it is python limitation but that's probably half-true. – Mike Oct 24 '18 at 07:08

0 Answers0