Giter Site home page Giter Site logo

redio's People

Contributors

agronholm avatar o-fedorov avatar tronic avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

redio's Issues

lacking of tests

Hi Tronic,
First of all thank you for this piece of software in trio land.
Unfortunetaly It will be difficult for me to promote it at my job if the project is lacking of tests :(
and I think I wouldn't be the only one with this problem.

Best regards

No license in repo

Hi there:)

I am interested in using redis with trio and had a look at the code in this repo and really liked what I saw. However as I might use this as work at some point I'd hesitate using code that is not under a permissive license (e.g. BSD, MIT etc.). Any thoughts?

Pipelining: database != 0 leads to SUBSCRIBE SELECT in wrong order

In the pubsub subscriber example with database !=0: with pipelining we send the SELECT after the SUBSCRIBE leading to

redis = redio.Redis("redis://localhost/9")

async for message in redis.pubsub("channel"):
    print (message)


redio.exc.ProtocolError: Pipelining error: bytes left unread: bytearray(b'-ERR only (P)SUBSCRIBE / (P)UNSUBSCRIB
E / PING / QUIT allowed in this context\r\n')

Wireshark shows:

*2
$9
SUBSCRIBE
$7
channel
*2
$6
SELECT
$1
9

The connections pool growth enormously

There are multiple issues with the connection pool:

  1. If a DB instance was not deleted, its connection will never be returned to the pool. And there is no guarantee that __del__ method is to be called soon. Since Redis._borrow_connection does not check for the number of borrowed connections, it is possible for the code to create a lot of connections, that causes an error OSError: all attempts to connect to <redis host> failed
  2. There can be multiple calls to __del__ method during garbage collection, adding the same connection to the pool.

For me, it seems that the pool management should be revisited, also I would add an ability to explicitly borrow and return the connection.

Retrieving from pubsub blocks?

I have 2 tasks started by nursery that process communication from different channels, one of them is PubSub reader. The code fetches messages one by one in tight loop:

while True:
    # await trio.sleep(0)
    if ws.closed:
        registry.remove(client_id=client)
        break
    user = registry.get(client_id=client)
    if user:
        message = await user.collect_message()
        payload = message.message
        payload['topic'] = message.topic
        try:
            await ws.send_message(json.dumps(payload))
        except ConnectionClosed:
            registry.remove(client_id=client)
            break

Fetch code:

    async def collect_message(self) -> Message:
        topic, message = await self._pubsub
        return Message(topic, message)

Once reader task starts executing it blocks the whole execution until 1st message arrives. I was able to overcome this by adding await trio.sleep(0) at the beginning of loop but I am not sure if it's a bug or I'm doing something stupid here. Tried to implement collect_message as async generator but the result was the same.

Any hints?

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.