Skip to content

When using RedisExpireStorage you get the exception: `redis.exceptions.DataError: Invalid input of type: 'function'. Convert to a bytes, string, int or float first. #12

@sluce23andme

Description

@sluce23andme

Basically huey.storage.RedisExpireStorage uses a lambda to define self.result_key instead of being a simple string:

class RedisExpireStorage(RedisStorage):
    # Redis storage subclass that adds expiration to task result values. Since
    # the Redis server handles deleting our results after the expiration time,
    # this storage layer will not delete the results when they are read.
    def __init__(self, name='huey', expire_time=86400, *args, **kwargs):
        super(RedisExpireStorage, self).__init__(name, *args, **kwargs)

        self._expire_time = expire_time

        self.result_prefix = rp = b'huey.r.%s.' % self.name.encode('utf8')
        encode = lambda s: s if isinstance(s, bytes) else s.encode('utf8')
        self.result_key = lambda k: rp + encode(k)

I have not looked into this any deeper at this point and have switched to PriorityRedisStorage for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions