You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Jake Howard b86b257278
Switch simple server to use threads for requests
2 years ago
.circleci Move linting to generic script 2 years ago
ipc_unix Switch simple server to use threads for requests 2 years ago
scripts Move linting to generic script 2 years ago
tests Refactor simple server client to class 2 years ago
.gitignore Setup project 2 years ago
.travis.yml Only support >=3.5 2 years ago
LICENSE Create LICENSE 2 years ago
README.md Close server in example 2 years ago
dev-requirements.txt Move black to separate script 2 years ago
setup.cfg Force payload to be dict, increase stability and speed 2 years ago
setup.py Only support >=3.5 2 years ago

README.md

IPC-Unix

CircleCI Build Status

Simple Inter-Process Communication using unix sockets for Python.

Note: Whilst mostly working, there's still some fairly common cases which haven't been tested. Use at your own risk until this message is removed.

Examples

For some more concrete examples, check out the tests/ directory.

Call / Response

from ipc_unix import Server, Client

class EchoServer(Server):
    def handle_request(self, request):
        return request

socket_path = '/tmp/sock.sock'
server = EchoServer(socket_path)
client = Client(socket_path)

print(client.send({"foo": "bar"}))
>>> {"foo": "bar"}

server.close()s

Pub-Sub

from ipc_unix import pubsub

socket_path = '/tmp/sock.sock'
publisher = pubsub.Publisher(socket_path)
subscriber = pubsub.Subscriber(socket_path)

publisher.write({"foo": "bar"})
print(self.subscriber.get_latest_message())
>>> {"foo": "bar"}

publisher.close()
subscriber.close()