Giter VIP home page Giter VIP logo

Comments (5)

coleifer avatar coleifer commented on May 27, 2024

That's odd, I don't see anything about it's removal in the changelog and it is still documented here:

https://redis.readthedocs.io/en/stable/commands.html#redis.commands.core.CoreCommands.register_script

Still here, too:

https://github.com/redis/redis-py/blob/master/redis/commands/core.py#L5379

Can you verify? Try importing the plain old redis client?

from walrus.

coleifer avatar coleifer commented on May 27, 2024

This is working fine for me:

In [1]: from walrus import *

In [2]: db = Database()

In [3]: db.register_script?
Signature: db.register_script(script: Union[bytes, str, memoryview]) -> redis.commands.core.Script
Docstring:
Register a Lua ``script`` specifying the ``keys`` it will touch.
Returns a Script object that is callable and hides the complexity of
deal with scripts, keys, and shas. This is the preferred way to work
with Lua scripts.
File:      ~/testenv/lib/python3.7/site-packages/redis/commands/core.py
Type:      method

In [4]: from redis import __version__

In [5]: __version__
Out[5]: '5.0.0'

from walrus.

g-rutter avatar g-rutter commented on May 27, 2024

I don't know what explains the difference, but I also had trouble with redis-py v5 and walrus. Here is a traceback

../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/<...>:520: in _reset
13:41:49       self._walrus_db = walrus.Database(*self._walrus_args, **self._walrus_kwargs)
13:41:49   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
13:41:49   
13:41:49   self = <walrus.database.Database object at 0x7ffc3c13ebb0>, args = ()
13:41:49   kwargs = {'host': 'redis1', 'port': '6379', 'retry_on_timeout': True}
13:41:49   script_dir = None
13:41:49   
13:41:49       def __init__(self, *args, **kwargs):
13:41:49           """
13:41:49           :param args: Arbitrary positional arguments to pass to the
13:41:49               base ``Redis`` instance.
13:41:49           :param kwargs: Arbitrary keyword arguments to pass to the
13:41:49               base ``Redis`` instance.
13:41:49           :param str script_dir: Path to directory containing walrus
13:41:49               scripts. Use "script_dir=False" to disable loading any scripts.
13:41:49           """
13:41:49           script_dir = kwargs.pop('script_dir', None)
13:41:49   >       super(Database, self).__init__(*args, **kwargs)
13:41:49   E       TypeError: object.__init__() takes exactly one argument (the instance to initialize)

This is inside a docker container from centos7 (!) during a conda build for our library (which explains the placehold stuff), and using pytest.

  • python 3.8.18
  • redis 5.0.1
  • walrus 0.9.3

In my local dev environment, with the same versions listed but not during conda build and using ubuntu 20.04, I got

Exception ignored in: <function Redis.__del__ at 0x7f060f339310>                            
Traceback (most recent call last):                                                                                                                                                       
  File "<...>lib/python3.8/site-packages/redis/client.py", line 491, in __del__
    self.close()                                                                            
  File "<...>lib/python3.8/site-packages/redis/client.py", line 506, in close
    self.connection_pool.disconnect()
AttributeError: 'Database' object has no attribute 'connection_pool'

Both are fixed by specifying redis-py<5

from walrus.

g-rutter avatar g-rutter commented on May 27, 2024

On second thought, it could be purely redis-py changes and nothing to do with this library

from walrus.

coleifer avatar coleifer commented on May 27, 2024

It seems OK to me on master for both:

>>> import redis
>>> redis.__version__
'5.1.0b3'
>>> from walrus import *
>>> db = Database()
>>> db.set('k1', 'v1')
True
>>> db.get('k1')
b'v1'
>>> db.close()
>>> del db

All tests are passing as well.

from walrus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.