systemd-socketserver
systemd-socketserver is a simple Python 3 package that provides the SystemdSocketServer class,
a socket server implementation that works in tandem with systemd's socket activation feature.
Very useful for writing basic socket activated daemons.
Installation
Install from PyPi:
pip install systemd-socketserver
Or clone from Git and install from source:
setup.py install
Basic Usage
For a full example see the example directory.
The following Python module, when activated via .socket unit, will echo the first sent line to the socket
then disconnect.
class EchoHandler(socketserver.StreamRequestHandler):
def handle(self):
self.data = self.rfile.readline()
self.wfile.write(self.data.upper())
server = systemd_socketserver.listen_server(EchoHandler)
if server is None:
print('this example only supports socket activation', file=sys.stderr)
return
server.listen_forever()
Features:
-
Supports and auto detects both listen and accept sockets (
Accept=true|falsein the.socketunit) -
Supports named file descriptors, making it easy to bind different handlers to different sockets.
This feature relies on functionality currently not present in the most recent package release of python-systemd, namely the
listen_fds_with_namesfunction. Callinglisten_servers_with_nameswill throw aNotImplementedExceptionin this case.Building python-systemd from source will include support for
listen_fds_with_namesand hence this feature will work.For an example of this functionality see the code in the
exampledirectory.
Known Limitations
- This module has only been tested with INET sockets.
- Better documentation TODO.
Metadata
Release files for systemd-socketserver 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| systemd_socketserver-1.0-py3-none-any.whl | Python 3 | none | any | Details for systemd_socketserver-1.0-py3-none-any.whl |
Release files / systemd_socketserver-1.0-py3-none-any.whl
| Download URL | systemd_socketserver-1.0-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
987a8bfbf28d959e7c2966c742ad7bad482f05e121077defcf95bb38267db9a8
|
|
BLAKE2b-256 checksum How to use checksums |
d84fb28b7f08880120a26669b080ca74487c8c67e8b54dcb0467a8f0c9f38ed6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0
|
Security for systemd-socketserver 1.0
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.