Ok so to end this thread, @popravich <https://github.com/popravich> told me 
that the problem is on the server side, since cancelling reader.read() 
doesn't actually stop the server from waiting for the request.

For the BLPOP timeout case, we should probably let the redis server handle 
the timeout (as the BPOP command let us do so).

To handle the CancelledSignal, @*popravich <https://github.com/popravich> * 
is going to rework the RedisPool and RedisConnection so that 
RedisConnection uses a pool to make sure that each command will be executed 
in a connection ready pool and that we can safely close a connection in 
case of CancelledError when waiting for the server answer.

Thank you all for your help on this.

Best regards,

Rémy

Le jeudi 9 avril 2015 15:54:22 UTC+2, Rémy Hubscher a écrit :
>
> I tried to use reader.feed_data() for that but the next call to yield 
> from reader.read() return the data feeded.
>
> Le jeudi 9 avril 2015 15:33:29 UTC+2, Rémy Hubscher a écrit :
>>
>> Ok so continuing to investigate, my question is summarize by the 
>> following:
>>
>> #!/usr/bin/env python
>> import asyncio
>> import hiredis
>> from aioredis.util import encode_command
>> from aioredis.errors import ProtocolError, ReplyError
>>
>>
>> @asyncio.coroutine
>> def run_me():
>>     reader, writer = yield from asyncio.open_connection("localhost", 6379)
>>     writer.write(encode_command("BLPOP", "channel", 0))
>>     try:
>>         task = asyncio.Task(reader.read(65536))
>>         data = yield from asyncio.wait_for(task, 1)
>>     except asyncio.TimeoutError:
>>         task.cancel()
>>         data = yield from reader.read(65536)
>>     finally:
>>         parser = hiredis.Reader(protocolError=ProtocolError,
>>                                 replyError=ReplyError)
>>         parser.feed(data)
>>         return parser.gets()
>>
>> data = asyncio.get_event_loop().run_until_complete(run_me())
>> print(data)
>>
>>
>> *How can I stop the reader in order to read it again later?*
>>
>

Reply via email to