pymprpc ===============================
version: 0.0.3
status: dev
author: hsz
email: hsz1273327@gmail.com
Desc
a rpc framework for message-pack rpc.
keywords:rpc,server,tcp
Feature
api seems to stdlib xmlrpc
easy to use, easy to debug
support stream response
Example
server
import platform
from pymprpc.server import SimpleMprpcServer
if platform.system() == "Windows":
try:
import aio_windows_patch as asyncio
except:
import warnings
warnings.warn(
"you should install aio_windows_patch to support windows",
RuntimeWarning,
stacklevel=3)
import asyncio
else:
import asyncio
try:
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ImportError:
pass
class MyMPRPCServer(SimpleMprpcServer):
pass
with MyMPRPCServer(("127.0.0.1", 5000), debug=True) as server:
server.register_introspection_functions()
@server.register_function()
def testfunc(a, b):
'''有help'''
return a + b
@server.register_function()
async def testcoro(a, b):
await asyncio.sleep(0.1)
return a + b
@server.register_function()
async def testcorogen(a, b):
for i in range(10):
await asyncio.sleep(0.1)
yield i + a + b
class TestClass:
def testclassmethod(self, a, b):
return a + b
async def testclasscoro(self, a, b):
await asyncio.sleep(0.1)
return a + b
async def testclasscorogen(self, a, b):
for i in range(10):
await asyncio.sleep(0.1)
yield i + a + b
t = TestClass()
server.register_instance(t)
server.run_forever()
sync client
import time
from pymprpc.client import RPC
with RPC(addr="tcp://admin:admin@127.0.0.1:5000",
debug=True) as rpc:
print(rpc.system.listMethods())
print(rpc.system.methodSignature("testclassmethod"))
print(rpc.system.methodHelp("testfunc"))
print(rpc.system.lenConnections())
print(rpc.system.lenUndoneTasks())
print(rpc.testclassmethod(1, 2))
print(rpc.testclasscoro(2, 3))
print(rpc.testcoro(5, 6))
print(rpc.testfunc(5, 4))
agen = rpc.testcorogen(1, 2)
for i in agen:
print(i)
time.sleep(200)
print("wait done")
# rpc.close()
print(rpc.testfunc())
async client
import asyncio
from pymprpc.client import AsyncRPC
async def main(loop):
async with AsyncRPC(
addr="tcp://admin:admin@127.0.0.1:5000",
loop=loop,
debug=True) as rpc:
print(await rpc.system.listMethods())
print(await rpc.system.methodSignature("testclassmethod"))
print(await rpc.system.methodHelp("testfunc"))
print(await rpc.system.lenConnections())
print(await rpc.system.lenUndoneTasks())
print(await rpc.testclassmethod(1, 2))
print(await rpc.testclasscoro(2, 3))
print(await rpc.testcoro(5, 6))
print(await rpc.testfunc(5, 4))
# await asyncio.sleep(200)
print("wait done")
print(await rpc.testfunc())
print("end")
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(main(loop))
except Exception as e:
raise e
Install
python -m pip install pymprpc
Documentation
TODO
Load balancing broker
Limitations
sync client do not support heartbeat and timeout
Metadata
Release files for pymprpc 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymprpc-0.0.3.tar.gz | 22.4 kB | Without provenance | Details for pymprpc-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymprpc-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pymprpc-0.0.3-py3-none-any.whl |
Total release size: 55.7 kB
Release files / pymprpc-0.0.3.tar.gz
| Download URL | pymprpc-0.0.3.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00eac8096b21d7b3afa20e986feb5912e5062d2ff5a2b77292493723eebe8296
|
|
BLAKE2b-256 checksum How to use checksums |
0eddcd336501b20a6dd011967c2a88e6993542e66b49013bb05b606fd0f6f7c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pymprpc-0.0.3-py3-none-any.whl
| Download URL | pymprpc-0.0.3-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ae941391d1ae87be04f1a9b010d9c02284f53e48e3543d0b58df4d639e1de84
|
|
BLAKE2b-256 checksum How to use checksums |
af444c4fd709abef6038b48e63c622f973ba374328959e7aa6562ee1f4a6a125
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pymprpc 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.