A rpc framework based on gevent/protobuf
Project description
A handy toolset.
Features
low level transport/protocol
high level stream/websocket
rpc support
custom combination of transport and protocol
useful ErrorManager
useful settings module
pluggable extensions, such as MiddlewareManager
handy pymaid console script
best effort performance
keep simple for use
Installation
pip install -U pymaid
Examples
import pymaid
from pymaid.net.stream import Stream
class Stream(Stream):
def data_received(self, data):
# cannot use asynchronous way since this is in io callback
self.write_sync(data)
async def main():
ch = await pymaid.net.serve_stream(
'tcp://127.0.0.1:8001', transport_class=Stream
)
async with ch:
await ch.serve_forever()
if __name__ == "__main__":
pymaid.run(main())
import pymaid
from pymaid.net.stream import Stream
class Stream(Stream):
def init(self):
self.data_size = 0
def data_received(self, data):
self.data_size += len(data)
async def wrapper(address, count):
stream = await pymaid.net.dial_stream(address, transport_class=Stream)
for _ in range(count):
await stream.write(b'a' * 1000)
stream.shutdown()
await stream.wait_closed()
assert stream.data_size == 1000 * count, (stream.data_size, 1000 * count)
async def main():
tasks = []
address = 'tcp://127.0.0.1:8001'
for x in range(100):
tasks.append(pymaid.create_task(wrapper(address, 1000)))
# await pymaid.wait(tasks, timeout=args.timeout)
await pymaid.gather(*tasks)
if __name__ == "__main__":
pymaid.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymaid-1.0.0a3.tar.gz
(78.8 kB
view hashes)
Built Distributions
Close
Hashes for pymaid-1.0.0a3-cp310-cp310-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c596debf91c6404b7a31d3bd2e37cf69cdd122ef7277d20168198bf5f4b24dd1 |
|
MD5 | 186c17d5c1f0f6039ce7c9e8ea06cabe |
|
BLAKE2b-256 | 9b2e98f654710ab54a546065a6082af8cd4d4d7e70416b92b75038f0248897e1 |
Close
Hashes for pymaid-1.0.0a3-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e42f3df0cbcebbb016a4d8e5c28bddfc864a72502929b97197255f7110841433 |
|
MD5 | b8b46eab4a6794277368c772e867a020 |
|
BLAKE2b-256 | b316f6b47b6b4f64f365a1e4e041639ae33966575f8c7ab06fed83e132c346e6 |
Close
Hashes for pymaid-1.0.0a3-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be345ab6616736439d6e4ca322e9be21ff4fbdc4e72db5116b11601c77e81ddc |
|
MD5 | 0b4b8f4d3439e491fc27f4f639530d55 |
|
BLAKE2b-256 | 7d35d89bf3fa7426b53790825f1bd393b9d767dd48b807720f54f3e6053df03b |
Close
Hashes for pymaid-1.0.0a3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 866c0b28e738eba4bc986fd3508ef7348cc33f1c43256614a9f9f2a66b1f0482 |
|
MD5 | 795197afd5f1127e09010278d7c1db36 |
|
BLAKE2b-256 | 743cd62123c0b8aab08e6faa53a81e91771f373f941e22c34448025e364072cf |