python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

Concurrent calls

Open AlexanderZender opened this issue 3 years ago • 0 comments

Hello,

Is the GRPC server stub only capable of handling 1 request at a time in a sync order? I have a heavy-loaded method that takes a while to complete, while it is working every other GRPC call is not answered until after said workload is finished. After completion, the other method calls will be handled in the requested order. The same reaction applies when calling the same heavy method twice, first the server will finish the entire call from the first request before starting the second request.

I use a Blazor web application as a client, that creates a new client for every request, so I was wondering if the python server of betterproto can not handle concurrent clients/requests? I implemented the server as shown in the example

async def main():
    server = Server([ControllerService()])
    context = SSLContext(protocol=ssl.PROTOCOL_TLSv1_2)
    context.load_cert_chain(certfile="certificate/server.crt", keyfile='certificate/server.key')
    await server.start(get_config_property('controller-server-adress'), get_config_property('controller-server-port'), ssl=create_secure_context())
    await server.wait_closed()

if __name__ == '__main__':
    logging.basicConfig()
    print("controller started")
    #serve()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    print('done.')

AlexanderZender avatar Aug 31 '22 16:08 AlexanderZender