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)
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}.")
def value(self, value_): self._value = utils.decode(value_)
def __str__(self): """ :return: the value of this Field as a decoded string. """ return str(utils.decode(self.value))
def test_decode_float(): assert utils.decode(1.23) == 1.23
def test_decode_int_null(): assert utils.decode(utils.null) is None
def test_decode_none(): assert utils.decode(None) is None
def test_decode_int(): assert utils.decode(123) == 123
def test_decode_str_null(): assert utils.decode(str(utils.null)) is None
def test_decode_str(): assert utils.decode("abc") == "abc"
def test_decode_bytearray(): assert utils.decode(bytearray("abc", encoding="utf-8")) == "abc"
def test_decode_bytes(): assert utils.decode(b"abc") == "abc"