Skip to main content

grpchook (grpc + hook) is an asynchronous Python gRPC bidirectional-streaming framework. Subclass BaseServer/BaseClient, override hooks — the base handles all gRPC plumbing.

Project description

grpchook

grpchook (gRPC + hook) is a Python framework for building asynchronous gRPC bidirectional-streaming services. Subclass BaseServer and BaseClient, override the hooks you need — the framework handles all gRPC plumbing.

PyPI Python License

Status: Work in Progress. The project is open source and will remain open source. Treat with caution. If you depend on it, pin your version.


Table of Contents


Disclaimer

Core concept by a human developer. AI was used to assist with unit and integration tests, examples, documentation, and selected code sections. Core logic has been reviewed by a human; the test suite has not been fully audited — there may be AI-introduced oversights. Please report any issues you find.

This software is provided "as is", without warranty of any kind. The developer is not responsible for any damage, data loss, security vulnerabilities, or other issues that may arise from using this software. You use it at your own risk. See LICENSE.txt for the full BSD 3-Clause terms.


When to Use and When Not to Use grpchook

When to Use grpchook

  • You need a simple, Python-based gRPC bidirectional streaming server and client.

  • You want a data exchange blueprint for developers or AI agents to build on top of.

  • You want a framework that can be extended with custom hooks for specific events.

  • You want to distribute clients to many different machines (e.g. voice recorder, voice to text, text to LLM, and vice versa until the final response is replayed)

    Example — four clients on four machines, all routed through one grpchook server:

    💡 Diagram requires the Markdown Preview Mermaid Support extension to render in VS Code.

    flowchart LR
        subgraph M1["📦 Machine 1"]
            VR["🎤 Voice Recorder"]
        end
        subgraph M2["📦 Machine 2"]
            STT["📝 Speech-to-Text"]
        end
        subgraph M3["📦 Machine 3"]
            LLM["🤖 LLM Processor"]
        end
        subgraph M4["📦 Machine 4"]
            RP["🔊 Voice Replay"]
        end
    
        SRV(["⚙️ grpchook Server"])
    
        VR  -->|"① audio"| SRV
        SRV -->|"① audio"| STT
        STT -->|"② transcript"| SRV
        SRV -->|"② transcript"| LLM
        LLM -->|"③ llm_response"| SRV
        SRV -->|"③ llm_response"| RP
    

When Not to Use grpchook

  • When you need a very large number of clients; the threading model may introduce overhead.
  • When you need direct peer-to-peer communication without a server intermediary; grpchook routes all messages through a central server.
  • You want a framework that supports multiple programming languages out of the box; grpchook is (currently) Python-only.

Requirements

  • Python 3.10 or later
  • A dedicated virtual environment is strongly recommended — gRPC version conflicts with other packages are common when using grpchook.

Installation

From PyPI

pip install grpchook

From Source

git clone https://github.com/fwkrumm/grpchook.git
cd grpchook
pip install -e .

Quick Start

Refer to HOW_TO.md for the full API reference and code examples. Alternatively run

python -m grpchook --generate-skeletons

to generate a very basic server and client skeleton in the current directory. Use

python -m grpchook --generate-interface-with-skeletons

to generate the skeletons along with a copy of the message.proto interface file in the current directory to modify which is then used by the skeletons.


Examples

Runnable examples are available in two locations:

  • examples/ — self-contained, scenario-focused examples
  • tests/integration/ — integration test scenarios covering a broad range of use cases

Run them on a machine with adequate resources; some scenarios are resource-intensive.


Testing

Install dev dependencies and run the unit tests:

pip install -r requirements_dev.txt
python -m unittest discover -s tests

Integration tests are in tests/integration/ and can be run via:

python tests/integration/run_integration_tests.py

Regenerating the gRPC Interface

If you modify grpchook/message.proto after cloning the repository, regenerate the Python bindings with:

python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. --pyi_out=. grpchook/message.proto

Note that all clients which connect to a server have to use the same proto schema version i.e. the same proto file. The different signals for the clients must be used in substructures:

message Payload {
    // For client A
    SomeTypeA payloadClientA = 1;

	// For client B
    SomeTypeB payloadClientB = 2;

    ...
}

ToDos & Roadmap

Performance & Stability

  • Evaluate replacing the threading model with asyncio if the performance gain justifies the API tradeoff.
  • Verify behavior when connections are interrupted mid-stream; ensure no ghost threads or queue deadlocks occur.

Planned Features

  • Multi-language client example (e.g., C++ or Rust).
  • SSL/TLS usage example.

Known Issues & Troubleshooting

TBD


Contributing

Contributions are welcome. Please open an issue first for major changes so the approach can be discussed. For bug fixes and small improvements, a pull request is sufficient.


License

BSD 3-Clause — see LICENSE.txt.


Release History

Version / Git Tag on Master Description
0.0.1 Initial public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grpchook-0.0.2.tar.gz (109.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grpchook-0.0.2-py3-none-any.whl (87.1 kB view details)

Uploaded Python 3

File details

Details for the file grpchook-0.0.2.tar.gz.

File metadata

  • Download URL: grpchook-0.0.2.tar.gz
  • Upload date:
  • Size: 109.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grpchook-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c72b1737a32ca23d1b1853d39d563f658701fefbbba36b98b94885990f607049
MD5 4664fcc4031a29f2c394438e417c9fc8
BLAKE2b-256 a7fd7d463b61c67035c5ef16acae51fa77bbd68c4cf7c856dc61b0a226d670be

See more details on using hashes here.

Provenance

The following attestation bundles were made for grpchook-0.0.2.tar.gz:

Publisher: pypi_publish.yml on fwkrumm/grpchook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grpchook-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: grpchook-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 87.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for grpchook-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9da8518318ad466d6ca3677630b538a252b4dea3127c9dc423858178f909d7a5
MD5 03d9c6b602a69be18b85912048e316c5
BLAKE2b-256 1703d300492a476a647bcf38310f47f53e4725383663932b5733fc0da78e4345

See more details on using hashes here.

Provenance

The following attestation bundles were made for grpchook-0.0.2-py3-none-any.whl:

Publisher: pypi_publish.yml on fwkrumm/grpchook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page