Tronic / redio

Redis client for Python Trio
22 stars 5 forks source link

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

Closed space88man closed 4 years ago

space88man commented 4 years ago

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
Tronic commented 4 years ago

Thanks for reporting this. I've fixed the issue and will push a fix as soon as I get the tests done and finish some refactoring of pubsub (to allow subscribing atomically before actually waiting for messages).

Tronic commented 4 years ago

This should be fixed in 0.5.2, released on pypi a moment ago. Please test and close the issue if it is now resolved.

space88man commented 4 years ago

The new release fixes my issue. Thank you.