Skip to main content

Stateful rpc for Python

Project description

PyPI version License Python Versions test suite Coverage Status

An asyncio compatible RPC framework for building distributed applications.

RMY provides a high level API allowing to expose objects from one process to the other. It frees programmers from having to handle communication between processes while still providing enough control when needed. The simplest possible use of RMY framework looks as follows.

import rmy

class Demo:
    async def greet(self, name):
        return f"Hello {name}!"


if __name__ == "__main__":
    rmy.run_tcp_server(8080, Demo())

This will expose an instance of the Demo object which can then be remotely accessed to as follows.

import rmy
from hello_rmy_server import Demo

if __name__ == "__main__":
    with rmy.create_sync_client("localhost", 8080) as client:
        demo_remote = client.fetch_remote_object(Demo)
        while True:
            print('Enter your name:')
            name = input()
            print(demo_remote.greet.eval(name))

One can easily also asynchronously iterate through results generated by another object remotely. MY provides robust ways to iterate over (asynchronous) iterators applying back pressure if required. This allows to implement trivially Pub-Sub or any other event notification pattern easily. A trivial example of remote generator iteration might look like this.

import random

class Demo:
    ...
    async def count(self):
        for i in range(1_000_000):
            await asyncio.sleep(random.uniform())
            yield i

One can remotely iterate through the values using a normal loop.

for i in demo_remote.count():
    print(i)

For smplicity sake we showcased examples in synchronous code. One can easily make those asynchronous by instanciating an asynchronous client.

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

rmy-0.1.5.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

rmy-0.1.5-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file rmy-0.1.5.tar.gz.

File metadata

  • Download URL: rmy-0.1.5.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.4.0

File hashes

Hashes for rmy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0173d53a016dc8dcf3ddb2db18d1039544b34902a05ee1e9c132ea581c8462bb
MD5 a0c51211ae1d88a06c7954d2c6af3288
BLAKE2b-256 e6b04feb7582b25aac04a81a6de1eaa4d15c4167295479c52d77e338667b7453

See more details on using hashes here.

Provenance

File details

Details for the file rmy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: rmy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.4.0

File hashes

Hashes for rmy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8faca6aefa566475210802e0bbb156f2e425c096956bde232dc4ef7352a73448
MD5 9d5fe03264ca437fc34520cc8f2cdd7a
BLAKE2b-256 a212c569c967a8fe1af4efe58358baade4a61e64e7ec9a5b0ee3e920ea045fce

See more details on using hashes here.

Provenance

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