Пример #1
0
    async def filter(
        self, *, session_id: str = "*", originator: str = "*"
    ) -> List[numbers.Integral]:

        matches = list()

        with await self.redis_pool as conn:
            cur = b"0"  # set initial cursor to 0
            while cur:
                cur, keys = await conn.scan(cur, match=f"{session_id}:{originator}:*")
                for key in keys:
                    store_id, store_origin, seq_num = utils.decode(key).split(":")
                    matches.append(int(seq_num))

        return sorted(matches)
Пример #2
0
    async def _send_channel_reader(self):
        try:
            with await self.redis_pool as conn:
                await conn.subscribe(self.SEND_CHANNEL)

                send_channel = conn.channels[self.SEND_CHANNEL]

                while await send_channel.wait_message():
                    message = await send_channel.get()
                    message = decoders.from_json(utils.decode(message))
                    asyncio.create_task(
                        self.send(message))  # Pass message on to pipeline

        except aioredis.ChannelClosedError:
            # Shutting down...
            logger.info(f"{self.name}: Unsubscribed from {send_channel.name}.")
Пример #3
0
 def value(self, value_):
     self._value = utils.decode(value_)
Пример #4
0
 def __str__(self):
     """
     :return: the value of this Field as a decoded string.
     """
     return str(utils.decode(self.value))
Пример #5
0
def test_decode_float():
    assert utils.decode(1.23) == 1.23
Пример #6
0
def test_decode_int_null():
    assert utils.decode(utils.null) is None
Пример #7
0
def test_decode_none():
    assert utils.decode(None) is None
Пример #8
0
def test_decode_int():
    assert utils.decode(123) == 123
Пример #9
0
def test_decode_str_null():
    assert utils.decode(str(utils.null)) is None
Пример #10
0
def test_decode_str():
    assert utils.decode("abc") == "abc"
Пример #11
0
def test_decode_bytearray():
    assert utils.decode(bytearray("abc", encoding="utf-8")) == "abc"
Пример #12
0
def test_decode_bytes():
    assert utils.decode(b"abc") == "abc"