Skip to main content

pipe-io-server

A trivial to use IPC solution based on POSIX named pipes and newlines.

Why?

When it comes to communication between processes, we often find that all we need is the simple abstraction of a text based message queue with a blocking send() and recv() to connect 2 processes.

We could use sockets for instance, but that requires writing lots of boilerplate. This can especially be a hassle if you want to support many programming languages, as you would have to develop and maintain your own bindings implementing your custom messaging protocol across all of them (turning the abstraction of a byte stream into a queue of messages).

You could also use a message broker like RabbitMQ or Redis, but that would force you to run a daemon in the background. You could choose something like ZeroMQ, but all abstractions come with costs (i.e how would you send a message to a ZMQ socket from a bash shell, or an environment where ZMQ bindings are not easily available?).

What if you didn't have to maintain any language bindings to integrate with different languages? What if you could rely on an API so trivial, that virtually every programming language already provides it?

Some developers like doing IPC by writing and reading lines of text to and from named pipes. It turns out that since a named pipe is like a file without seek() (stdin or stdout are pipes), you can use the readline and print utilities of programming languages to use them. Opening a pipe will block until the other side opens it and reading from it also blocks until data is available. Just what we want!

The only issue is that writing a server for pipe based IO is not that trivial if you wish to avoid blocking your main thread: you have to start a thread for each pipe, avoid losing messages when clients are opening and closing your pipes, deal with race conditions and so on. It is especially hard to properly stop such a server: deadlocks are very easy to encounter when juggling around with threads blocking on pipe operations. This gets even more difficult if you wish your server to be resilient against irregular client behaviour, such as the deletion of a named pipe while a thread is blocking on it. This may sound discouraging, but this is the exact reason why I've written this package: so you won't have to. And solving all these issues are worth it in the end: writing clients is as trivial as it gets.

What?

This package provides robust, asynchronous servers capable of IO over a text-based, newline delimited protocol using named pipes. This makes it extremely easy to integrate any external process as a plugin into your application: clients can just open file descriptors for reading/writing without worrying about anything else.

Examples

A few lines of code are worth a 100 lines of API documentation. You can find a simple usage example of this package in echo_server.py.

A client replying to each message of the server in just a few lines of bash (send and recv are the paths of the pipes):

while IFS= read -r message; do
    printf "Received: ${message}\n"
    # ... do something ...
    printf "Some response\n" > "send"
done < "recv"

Some more examples:

  • pipe_io_server/clients contains examples on how to use pipes in different languages
  • pipe_io_server/test_pipe_io_server.py contains a relatively comprehensive suite of unit tests

Metadata

Release files for pipe-io-server 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipe-io-server 1.0.3
File Size Uploaded Provenance Actions
pipe_io_server-1.0.3.tar.gz 11.9 kB Without provenance Details for pipe_io_server-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pipe-io-server 1.0.3
File Interpreter ABI Platform Actions
pipe_io_server-1.0.3-py3-none-any.whl Python 3 none any Details for pipe_io_server-1.0.3-py3-none-any.whl

Total release size: 29.7 kB

Release files / pipe_io_server-1.0.3.tar.gz

Download URL pipe_io_server-1.0.3.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
75a93b1507e962102b1afd521d47c459aec5a7706cdfe24b6d5c6ffef04ceca8
BLAKE2b-256 checksum
How to use checksums
42e24d8f23e857bcf058e10b800a633eb5bd1adee0703c0a6fe194c01f923dfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

Release files / pipe_io_server-1.0.3-py3-none-any.whl

Download URL pipe_io_server-1.0.3-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cabbb5a5fcec2874f7b9c4f095b9fdca3a059ae6141fd1c68f7814f0a85b4890
BLAKE2b-256 checksum
How to use checksums
869bbcdddc5db19f965062c97c61add38da3ed263fd15e6c529e192abda3f4fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

Security for pipe-io-server 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page