How to use the hiredis.Reader function in hiredis

To help you get started, we’ve selected a few hiredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redis / hiredis-py / test / reader.py View on Github external
def test_protocol_error_with_custom_class(self):
    self.reader = hiredis.Reader(protocolError=RuntimeError)
    self.reader.feed(b"x")
    self.assertRaises(RuntimeError, self.reply)
github redis / hiredis-py / test / reader.py View on Github external
def setUp(self):
    self.reader = hiredis.Reader()
github redis / hiredis-py / test / reader.py View on Github external
def test_bulk_string_with_invalid_encoding(self):
    self.reader = hiredis.Reader(encoding="unknown")
    self.reader.feed(b"$5\r\nhello\r\n")
    self.assertRaises(LookupError, self.reply)
github aio-libs / aioredis / aioredis / connection.py View on Github external
def __init__(self, reader, writer, *, address, encoding=None, loop=None):
        if loop is None:
            loop = asyncio.get_event_loop()
        self._reader = reader
        self._writer = writer
        self._address = address
        self._loop = loop
        self._waiters = deque()
        self._parser = hiredis.Reader(protocolError=ProtocolError,
                                      replyError=ReplyError)
        self._reader_task = async_task(self._read_data(), loop=self._loop)
        self._db = 0
        self._closing = False
        self._closed = False
        self._close_waiter = create_future(loop=self._loop)
        self._reader_task.add_done_callback(self._close_waiter.set_result)
        self._in_transaction = None
        self._transaction_error = None  # XXX: never used?
        self._in_pubsub = 0
        self._pubsub_channels = coerced_keys_dict()
        self._pubsub_patterns = coerced_keys_dict()
        self._encoding = encoding
github DingGuodong / LinuxBashShellScriptForOps / functions / nosql / cache / pyRedisOps_hiredis.py View on Github external
#!/usr/bin/python
# encoding: utf-8
# -*- coding: utf8 -*-
"""
Created by PyCharm.
File:               LinuxBashShellScriptForOps:pyRedisOps.py
User:               Guodong
Create Date:        2016/9/7
Create Time:        10:36
 """

import hiredis

reader = hiredis.Reader()
reader.feed("$5\r\nhello\r\n")
print(reader.gets())
reader.feed("*2\r\n$5\r\nhello\r\n")
print(reader.gets())
reader.feed("$5\r\nworld\r\n")
print(reader.gets())
github schlitzered / pyredis / pyredis / connection.py View on Github external
def _connect(self):
        if self._closed:
            raise PyRedisConnError('Connection Gone')
        if self.host:
            sock = self._connect_inet46()
        else:
            sock = self._connect_unix()
        self._sock = sock
        if self._encoding:
            self._reader = Reader(encoding=self._encoding)
        else:
            self._reader = Reader()
        self._authenticate()
        if not self._sentinel:
            self._setdb()
            self._set_read_only()
        self._sock.settimeout(self._read_timeout)
github gmr / tredis / tredis / client.py View on Github external
:param bool clustering: Toggle the cluster support in the client
        :param bool auto_connect: Toggle the auto-connect on creation feature

        """
        self._buffer = bytes()
        self._busy = locks.Lock()
        self._closing = False
        self._cluster = {}
        self._clustering = clustering
        self._connected = locks.Event()
        self._connect_future = concurrent.Future()
        self._connection = None
        self._discovery = False
        self._hosts = hosts
        self._on_close_callback = on_close
        self._reader = hiredis.Reader()
        self.io_loop = io_loop or ioloop.IOLoop.current()
        if not self._clustering:
            if len(hosts) > 1:
                raise ValueError('Too many hosts for non-clustering mode')
        if auto_connect:
            LOGGER.debug('Auto-connecting')
            self.connect()
github abhinavsingh / async_pubsub / async_pubsub / redis_pubsub.py View on Github external
def on_connect(self):
        self.stream.set_close_callback(self.on_close)
        self.stream.read_until_close(self.on_data, self.on_streaming_data)
        self.reader = hiredis.Reader()
        self.connected()
github boramalper / pydis / pydis / __main__.py View on Github external
def __init__(self):
        self.dictionary = dictionary
        self.response = collections.deque()
        self.parser = hiredis.Reader()
        self.transport = None  # type: asyncio.transports.Transport
        self.commands = {
            b"COMMAND": self.command,
            b"SET": self.set,
            b"GET": self.get,
            b"PING": self.ping,
            b"INCR": self.incr,
            b"LPUSH": self.lpush,
            b"RPUSH": self.rpush,
            b"LPOP": self.lpop,
            b"RPOP": self.rpop,
            b"SADD": self.sadd,
            b"HSET": self.hset,
            b"SPOP": self.spop,
            b"LRANGE": self.lrange,
            b"MSET": self.mset,

hiredis

Python wrapper for hiredis

MIT
Latest version published 8 days ago

Package Health Score

85 / 100
Full package analysis

Similar packages