Getting started with
- gRPC
- Python
- Test Driven Development
- Docs-as-code
- Visual Studio Code
Check if your machine already provides Python 3.12 and VS Code
Open a Terminal with a bash shell. On Windows use git-bash and check for them:
code --version
python3 --version
Positive responses and fitting Python version? Then your're all set. Skip next following and proceed with the next but one chapter.
Negative responses? Complete work environment. You may be guided by the next chapter.
You might want to use the package manager Scoop for that. In that case you might need to install it following the instructions on their website.
Close the shell (it was one with a Powershell). Important environment variables will be available only in freshly opened shells You'll open a new Terminal with git-bash. In the processing steps.
Install Python 3.12 via Scoop:
scoop bucket add versions
scoop install python312
Install VSCode via Scoop:
scoop bucket add extras
scoop install vscode
See Install Python 3.12 on Ubuntu 22.04
See Install VSCode on Ubuntu 22.04
If not already done, create fork of this repository.
In your fork create Codespace.
You're all set.
Open a Terminal and ake sure that the current work directory is the repository root folder.
Install global python package requirements:
python3 -m pip install -r requirements.txt
Create virtual python development environment:
pipenv install --dev
Get rid of annoying pipenv warnings later on:
export PIPENV_VERBOSITY=-1 # Supress warnings when pipenv started being already in virtual environment
Change into source folder:
cd src
Generate python code from message definitions in protobuf language:
pipenv run python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. grpc_in_the_snake_pit/helloworld.proto
Start the server in an own subprocess by:
pipenv run python3 -m grpc_in_the_snake_pit.server &
Now the server runs persistently in an endless loop in the background.
Start the client by:
pipenv run python3 -m grpc_in_the_snake_pit.client
The client sends only one message to the server and waits for the reply before terminating itself.
You need to re-start the client again to repeat the interchange of that single message.
You can stop the server by killing the subprocess the server runs in. Because it's the only (and so most recent) subprocess of your bash session it's pid (process identification number) is in built-in variable $!
. It can be killed via:
kill $!
Remove relicts of code generation and run/test:
rm -rf **/*_pb2*.py
rm -rf **/__pycache__ ; rm -rf **/*.pyc
rm -f .coverage ; rm -rf .coverage-dir
Remove work environment:
rm -f Pipfile.lock
rm -rf .venv/ ; git restore .venv/