Skip to main content

A lightweight Python RPC library for remote function calls with async support and resource management

Project description

pyremote

A simple and lightweight library for remote function calls

English | 中文

Usage

Here is the most intuitive example

server.py

import asyncio
from axirpc import NetworkServer, NetworkConnect


async def on_accept(conn: NetworkConnect):
    say("accept")
    await asyncio.sleep(1)
    conn.disconnect()


server = NetworkServer(("127.0.0.1", 5566), on_accept)


@server.register_func
def say(msg: str):
    print(msg)


async def main():
    await server.run()


asyncio.run(main())

client.py

import asyncio
from axirpc import NetworkConnect

connect = NetworkConnect(("127.0.0.1", 5566))


@connect.register_func
def say(msg: str):
    print(msg)


async def main():
    await connect.run()


if __name__ == '__main__':
    asyncio.run(main())

First run server.py, then run client.py, and "accept" will appear in the client's console before it stops

Adding Resources

Resources with consistent IDs can be added to both parties using the method above. These resources can then be directly passed as parameters during function calls.

server.py

async def on_accept(conn: NetworkConnect):
    say(res)
    await asyncio.sleep(1)
    conn.disconnect()

server = NetworkServer(("127.0.0.1", 5566), on_accept)
res = object()
server.res_man.register(res, uuid.UUID("00000000-0000-0000-0000-000000000000"))

@server.register_func
def say(a):
    print(a)

client.py

connect = NetworkConnect(("127.0.0.1", 5566))
res = object()
connect.res_man.register(res, uuid.UUID("00000000-0000-0000-0000-000000000000"))

@connect.register_func
def say(a):
    print(a)

The running result will now be: <object object at 0x000001C5AD554F50>

Future Tasks

  • Add object-oriented support
  • More detailed README documentation...
  • Add more extension options
  • Add logging

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

axi_rpc-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axi_rpc-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file axi_rpc-0.1.0.tar.gz.

File metadata

  • Download URL: axi_rpc-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for axi_rpc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c24fb4d0682a3227b9707657822deba25984099009824ecd844e3581e0b48abd
MD5 bed40cbcdc2efc977956f0ea9b8f8869
BLAKE2b-256 3081fc5aa4167f63df9c0f13d15d2c8e1995ce7732046844e63d3c7fd9ea07c6

See more details on using hashes here.

File details

Details for the file axi_rpc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: axi_rpc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for axi_rpc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad64981418dec96126fd8093a0214ad573ba27285047e39ff6108f30b76ed727
MD5 31735e0638113d3eefc7e5578c33dbc6
BLAKE2b-256 4ccd65578d66633e9f7e065055d8353b4be9ecade0321c944776cde7c2b34355

See more details on using hashes here.

Supported by

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