Skip to main content

No project description provided

Project description

rpc.py

An easy-to-use and powerful RPC framework. Base WSGI & ASGI.

Based on WSGI/ASGI, you can deploy the rpc.py server to any server and use http2 to get better performance.

Install

Install from PyPi:

pip install rpc.py

Install from github:

pip install git+https://github.com/abersheeran/rpc.py@setup.py

Usage

Server side:

import uvicorn
from rpcpy import RPC

app = RPC(mode="ASGI")


@app.register
async def sayhi(name: str) -> str:
    return f"hi {name}"


if __name__ == "__main__":
    uvicorn.run(app, interface="asgi3", port=65432)

OR

import uvicorn
from rpcpy import RPC

app = RPC(mode="WSGI")


@app.register
def sayhi(name: str) -> str:
    return f"hi {name}"


if __name__ == "__main__":
    uvicorn.run(app, interface="wsgi", port=65432)

Client side:

import httpx
from rpcpy.client import Client

app = Client(httpx.Client(), base_url="http://127.0.0.1:65432/")


@app.remote_call
def sayhi(name: str) -> str:
    ...


if __name__ == "__main__":
    print(sayhi("rpc.py"))

OR

import httpx
from rpcpy.client import Client

app = Client(httpx.AsyncClient(), base_url="http://127.0.0.1:65432/")


@app.remote_call
async def sayhi(name: str) -> str:
    ...


if __name__ == "__main__":
    import asyncio
    print(asyncio.get_event_loop().run_until_complete(sayhi("rpc.py")))

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

rpc.py-0.1.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

rpc.py-0.1.1-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file rpc.py-0.1.1.tar.gz.

File metadata

  • Download URL: rpc.py-0.1.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.8 Linux/5.3.0-1032-azure

File hashes

Hashes for rpc.py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 588532a65b81c8cb4f90de58165225fd6e3db87d78c84c658610f29b6a7151c7
MD5 3fa66fa57c8b63048990a40d16d133f1
BLAKE2b-256 d5a6d0c947f18507ed8f73b437ee67788adc1db3f399cb0841513e7ae75ede51

See more details on using hashes here.

File details

Details for the file rpc.py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rpc.py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.8 Linux/5.3.0-1032-azure

File hashes

Hashes for rpc.py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c606b5c06aaf2df1902a5112cde83681c8292abc4722cfe186d766b511ca45ce
MD5 edc241b055487ede37906ac437226f42
BLAKE2b-256 8d36ec13f44680dc3323fd08b33caa1ff96566ba33051233c0967293d12cbb7b

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