Skip to main content

Effortless Python RPC with ZeroMQ

Project description

wirepickle

Effortless python remote procedure calling with pickle over ZeroMQ. Allows you to expose a single class instance as an API server over every transport layer that ZeroMQ provides.

Quick Setup

Install wirepickle using your favorite package manager:

$ pip install wirepickle

Server

Next, on your server, annotate the methods you want to expose with the @expose decorator:

from wirepickle.server import expose, Server

class Foo:
    @expose('bar')
    def bar(self):
        print('bar')
        return 0

    @expose('baz')
    def baz(self, arg1, kwarg1='baz'):
        print(kwarg1)
        return self.bar() + arg1

Note that you can return anything that can be pickled as a return value, and that stdout will be mirrored to the client.

Then, pass an instance of the class to the Server constructor to create the server. To start listening, call the Server#listen() method on the constructed server with a bind URI:

if __name__ == '__main__':
    instance = Foo()

    Server(instance).listen('tcp://*:12345')

Client

Simply pass a URI to connect to and start using the methods.

from wirepickle.client import Client

foo = Client('tcp://127.0.0.1:12345')

foo.bar()

If desired, you can pass a timeout kwarg to the Client constructor:

foo = Client('tcp://127.0.0.1:12345', timeout=1_000) # milliseconds

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

wirepickle-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

wirepickle-1.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file wirepickle-1.0.1.tar.gz.

File metadata

  • Download URL: wirepickle-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for wirepickle-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6ddd35e4eae010a856c02aa18c47a6228f763a95ead6a96a3a0d540e865263fd
MD5 d3e38c6e37432d21d799b344332c8070
BLAKE2b-256 7608e1fd7b610f366a616eaf775b45fc5c6646f131325ef296c1003739ce021d

See more details on using hashes here.

File details

Details for the file wirepickle-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: wirepickle-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for wirepickle-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2625e5330f22906b0c318bebad66b7c12661d2ac4e6615439d108dc5941e87d
MD5 265bc1168460718fb99037db62b9bdc0
BLAKE2b-256 847beb1c815201692a54eb06e7df6401c3fbe3b8c340226bac985005784dab7b

See more details on using hashes here.

Supported by

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