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