Giter Club home page Giter Club logo

aiorpc's People

Contributors

abitfan avatar brglng avatar choleraehyq avatar dmig avatar kathiresan-jayabalan avatar markuspi avatar nedsociety avatar pyneda avatar volfco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aiorpc's Issues

Python 3.10: asyncio's loop got removed

In Python 3.10, for many of asyncio's higher-level functions, the loop parameter got removed.

Consequently, aiorcp yields TypeError: create_connection() got an unexpected keyword argument 'loop'.

One responsible line seems to be in client.py: await asyncio.open_connection(self._host, self._port, loop=self._loop)

Way to enforce argument types and optional arguments

I think it would be awesome if there was a way to define what kind of input a function takes, if it's required, and a way to enforce the type (i.e. str, int). Of the top of my head, we could do something like this:

@aiorpc.method({
    'id': [str, True],
    'ttl': [int, False, 86400]
})
async def set_ttl(payload):
    ...

All decorated functions would be registered as methods, and the provided dict would list the name of the arguments, and then the value would be a list- Type, Required, Default (optional). On the backend we could implement our own validation logic or build json schema objects on the fly.

I see two advantages:

  1. A way to abstract away from the requirement of implementing validation logic inside each function.
  2. We can have optional arguments in methods (which is always cool)

Thoughts?

Registered handle timeout is not passed to client

When the wait_for for the callback of an async function times out an exception is raised. It's then sent over to the client.
However, the info from the exception is extracted using 'str' (server.py:165):
await _send_error(conn, str(e), msg_id)
which returns None, ultimately raising no exception at the client.

Change 'str' to 'repr', for instance, will correctly cause an exception to be raised in the client side.

Add statsd/dogstatsd metrics

Metrics describing method performance would be nice.

I'm thinking of having a common function, such as _trace that takes a metric name (like aiorpc.server.request.duration), a dict of tags, type (timing, gauge), and a value (for timing).

Then you could call set_metric_backend with either aiorpc.metrics.dogstatsd or aiorpc.metrics.statsd. I think default will be dogstatsd, as datadog (and other hosted solutions) and telegraf support dogstatsd type tags.

Does this library follow a standard MsgPack based standard?

Is there a standard being following here?

I'm asking because I'm making some improvements for my own use, such as improved exception handling, which are changing some parts of the payload being sent back and forth. I'd love to merge them back in, but if there is a standard being followed I don't want to break it.

Logs Filled with 'Timeout when _send_error 'NoneType' object has no attr...'

I have been trying this library out, and it seems perfect for what we need.

However, whenever a client calls any function on the servers the logs are filled with the following error:

ERROR:aiorpc.aiorpc.server:Exception object of type 'NoneType' has no len() raised when _parse_request None
2018-05-23 15:26:14,108 aiorpc.aiorpc.server ERROR    Timeout when _send_error 'NoneType' object has no attribute '__call__' to ('127.0.0.1', 62243)
ERROR:aiorpc.aiorpc.server:Timeout when _send_error 'NoneType' object has no attribute '__call__' to ('127.0.0.1', 62243)

I get many of those entries every second.

Any idea what's wrong?

Server spins if client doesn't close connection

Using the following code example

from aiorpc import RPCClient

import asyncio
import uvloop
import time

async def do(cli):
    await client.call('test_method', 'abc')
    time.sleep(5)
    await client.call('test_method', 'abc')

loop = uvloop.new_event_loop()
asyncio.set_event_loop(loop)
client = RPCClient('127.0.0.1', 6000)
loop.run_until_complete(do(client))
client.close()

Will cause the server to freak out, eating up RAM and CPU until the client closes the connection. I would recommend adding a timeout on the server side.

Update version on PyPi

The latest version on PyPi is v0.1.3, published two years ago on May 12, 2018.

Awesome features are missing from v0.1.3., like async with.

Thanks!

Memory overflow

Client:

for i in range(0, 20):
    loop = uvloop.new_event_loop()
    asyncio.set_event_loop(loop)
    client = RPCClient('proxy', 6000, timeout=100)
    loop.run_until_complete(do(client))
    # client.close()  <-- specifically don't close connection for reproduce
import time
time.sleep(100)

You catch memory overflow and 100% of CPU loading after 10-20 seconds. Seems like you have a problem here aiorpc/server.py:124

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.