Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResponseError: Missing library metadata #3307

Open
eromoe opened this issue Jul 9, 2024 · 0 comments
Open

ResponseError: Missing library metadata #3307

eromoe opened this issue Jul 9, 2024 · 0 comments

Comments

@eromoe
Copy link

eromoe commented Jul 9, 2024

Version: redis-5.0.7
Platform: Python 3.9 on Windows 10
Description:

docs: https://redis.io/docs/latest/commands/function-load/

redis-cli is fine

create redis from docker

docker run -d --name redis_ts3 -p 16379:6379 redis/redis-stack-server
docker exec -it redis_ts3 /bin/bash && redis-cli

Add function without error

127.0.0.1:6379> FUNCTION LOAD "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
"mylib"
127.0.0.1:6379>

redis-py raise error

import redis

settings = {
    'host': 'localhost',
    'port': 16379,
    'db': 0,
    'password': None,
}

r = redis.Redis(**settings)
r.function_load("#!lua name=mylib2 \n redis.register_function('myfunc2', function(keys, args) return args[1] end)")

error:

---------------------------------------------------------------------------
ResponseError                             Traceback (most recent call last)
Cell In[8], line 1
----> 1 r.function_load(
      2 '''
      3 #!lua name=mylib
      4 redis.register_function('myfunc', function(keys, args) return args[1] end)
      5 '''
      6 )

File c:\envs\quant\lib\site-packages\redis\commands\core.py:6014, in FunctionCommands.function_load(self, code, replace)
   6012 pieces = ["REPLACE"] if replace else []
   6013 pieces.append(code)
-> 6014 return self.execute_command("FUNCTION LOAD", *pieces)

File c:\envs\quant\lib\site-packages\redis\client.py:545, in Redis.execute_command(self, *args, **options)
    542 conn = self.connection or pool.get_connection(command_name, **options)
    544 try:
--> 545     return conn.retry.call_with_retry(
    546         lambda: self._send_command_parse_response(
    547             conn, command_name, *args, **options
    548         ),
    549         lambda error: self._disconnect_raise(conn, error),
    550     )
    551 finally:
    552     if not self.connection:

File c:\envs\quant\lib\site-packages\redis\retry.py:46, in Retry.call_with_retry(self, do, fail)
     44 while True:
     45     try:
---> 46         return do()
     47     except self._supported_errors as error:
     48         failures += 1

File c:\envs\quant\lib\site-packages\redis\client.py:546, in Redis.execute_command.<locals>.<lambda>()
    542 conn = self.connection or pool.get_connection(command_name, **options)
    544 try:
    545     return conn.retry.call_with_retry(
--> 546         lambda: self._send_command_parse_response(
    547             conn, command_name, *args, **options
    548         ),
    549         lambda error: self._disconnect_raise(conn, error),
    550     )
    551 finally:
    552     if not self.connection:

File c:\envs\quant\lib\site-packages\redis\client.py:522, in Redis._send_command_parse_response(self, conn, command_name, *args, **options)
    518 """
    519 Send a command and parse the response
    520 """
    521 conn.send_command(*args)
--> 522 return self.parse_response(conn, command_name, **options)

File c:\envs\quant\lib\site-packages\redis\client.py:562, in Redis.parse_response(self, connection, command_name, **options)
    560         options.pop(NEVER_DECODE)
    561     else:
--> 562         response = connection.read_response()
    563 except ResponseError:
    564     if EMPTY_RESPONSE in options:

File c:\envs\quant\lib\site-packages\redis\connection.py:536, in AbstractConnection.read_response(self, disable_decoding, disconnect_on_error, push_request)
    534 if isinstance(response, ResponseError):
    535     try:
--> 536         raise response
    537     finally:
    538         del response  # avoid creating ref cycles

ResponseError: Missing library metadata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant