mirror of
https://github.com/php-win-ext/grpc.git
synced 2026-04-24 09:18:16 +02:00
41ec08c69a
* Update third_party/protobuf * run tools/distrib/python/make_grpcio_tools.py * regenerate protos for ruby, php * update build_handwritten.yaml * regenerate projects * Build - Use :well_known_type_protos instead of :well_known_protos * Fix target * Update upb * Update Python for Protobuf 4.21 (#140) * Update protobuf dependency on grpcio-tools * Off by one * Drop python 3.6 support * Try upgrading pip * And in the other script * Try to figure out if we're compatible with abi3 * See what we've already got installed * Update the requirements.txt file I didn't know existed * And here too * See what's installed * Let's try that again * Remove * Try to confirm version * Let me see the generated code * Fix non-Bazel test runner * Work for all test directories * Regenerate example protos * Clean up * Generate .pyi files * Fix type checking and linting * Exclude pyi files from isort * Upgrade to 3.21.4 * Update iwyu to get around messy protobuf IWYU rules Co-authored-by: Richard Belleville <gnossen@gmail.com>
gRPC Python Non-Blocking Streaming RPC Client Example
The goal of this example is to demonstrate how to handle streaming responses without blocking the current thread. Effectively, this can be achieved by converting the gRPC Python streaming API into callback-based.
In this example, the RPC service Phone simulates the life cycle of virtual
phone calls. It requires one thread to handle the phone-call session state
changes, and another thread to process the audio stream. In this case, the
normal blocking style API could not fulfill the need easily. Hence, we should
asynchronously execute the streaming RPC.
Steps to run this example
Start the server in one session
python3 server.py
Start the client in another session
python3 client.py
Example Output
$ python3 server.py
INFO:root:Server serving at [::]:50051
INFO:root:Received a phone call request for number [1415926535]
INFO:root:Created a call session [{
"sessionId": "0",
"media": "https://link.to.audio.resources"
}]
INFO:root:Call finished [1415926535]
INFO:root:Call session cleaned [{
"sessionId": "0",
"media": "https://link.to.audio.resources"
}]
$ python3 client.py
INFO:root:Waiting for peer to connect [1415926535]...
INFO:root:Call toward [1415926535] enters [NEW] state
INFO:root:Call toward [1415926535] enters [ACTIVE] state
INFO:root:Consuming audio resource [https://link.to.audio.resources]
INFO:root:Call toward [1415926535] enters [ENDED] state
INFO:root:Audio session finished [https://link.to.audio.resources]
INFO:root:Call finished!