New issue 200 by bartosz.blimke: It's not possible to close blocking
(BLPOP/BRPOP) connections with QUIT
http://code.google.com/p/redis/issues/detail?id=200
What steps will reproduce the problem?
telnet localhost 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
BRPOP foobar_list 0
QUIT
What is the expected output?
I would like to close Redis connection.
What do you see instead?
There is no way to close connection. The only way is to terminate client,
and wait for connection to expire on server side.
This is especially problematic in relation to issue 199.
What version of the product are you using? On what operating system?
Redis 1.3.6 from trunk. Snow Leopard
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Why don't you use the timeout on blocking operations?
--
I can use timeout which means, I have to do some kind of long polling.
I guess I still have to do long polling because of the issue 158.
Even if I use timeout on blocking operations I'm still not able to tell
redis "ok, I'm done,
don't feed me with any more data" at any time I want. I need to accept the
fact redis will
think I'm blocking until timeout is reached.
Sorry I meant issue 155 not 158 in the last comment.
What are the alternatives here? It is surely possible to find some way to
unblock the client, like sending any other command having the effect of
unblocking it, but think at it from the point of view of a library client:
anyway 99% of times this is going to use blocking I/O... so we are just
moving the problem.
IMHO the current behavior is ok, I'll leave this issue open for a few weeks
looking for feedbacks.
Thanks for reporting,
Salvatore
Problem is still actual:
I am use redis from python (celery), and use BRPOP to get data from redis.
If I using infinite timeout in BRPOP, and need in some cases close
connection then BRPOP is still active. So, I am trying do it gracefully and
use socket shutdown function (close receiving). After it, if redis sent any
data, I can process it, not lose.
But now I am discover that if message size is big (i.e., ~6000 bytes),
redis sent it, but client receives only 1448 bytes (TCP packet size?). In
that case client not received messages, and redis also remove value from
queue - data loses.
I don't know, is it possible redis to check that data is actually sent to
client?
Stop closing the connection half-way, set the timeout on the Python side to
be lower than the Redis server timeout, and retry on failure to get an
item. That will prevent data loss, and will take an additional 2 lines of
Python to make happen. I've included the implementation which will solve
your problem below:
result = None
while not QUIT and result is None:
result = connection.brpop([key], 60)