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

Does not work with redis-py 3.2 #235

Closed
MattBlack85 opened this issue Feb 18, 2019 · 5 comments
Closed

Does not work with redis-py 3.2 #235

MattBlack85 opened this issue Feb 18, 2019 · 5 comments

Comments

@MattBlack85
Copy link

MattBlack85 commented Feb 18, 2019

If I install 1.0.1 and try to execute what doc says I obtain the following error:

In [1]: import fakeredis                                                                                                                                                                                                                                                                                                   

In [2]: r = fakeredis.FakeStrictRedis()                                                                                                                                                                                                                                                                                    

In [3]: r.set('a', 'b')                                                                                                                                                                                                                                                                                                    
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-9aae901f3e7b> in <module>
----> 1 r.set('a', 'b')

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/client.py in set(self, name, value, ex, px, nx, xx)
   1449         if xx:
   1450             pieces.append('XX')
-> 1451         return self.execute_command('SET', *pieces)
   1452 
   1453     def __setitem__(self, name, value):

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/elasticapm/instrumentation/packages/base.py in call_if_sampling(self, module, method, wrapped, instance, args, kwargs)
    103         transaction = get_transaction()
    104         if not transaction or not transaction.is_sampled:
--> 105             return wrapped(*args, **kwargs)
    106         else:
    107             return self.call(module, method, wrapped, instance, args, kwargs)

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/elasticapm/instrumentation/packages/base.py in call_if_sampling(self, module, method, wrapped, instance, args, kwargs)
    103         transaction = get_transaction()
    104         if not transaction or not transaction.is_sampled:
--> 105             return wrapped(*args, **kwargs)
    106         else:
    107             return self.call(module, method, wrapped, instance, args, kwargs)

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/client.py in execute_command(self, *args, **options)
    770         pool = self.connection_pool
    771         command_name = args[0]
--> 772         connection = pool.get_connection(command_name, **options)
    773         try:
    774             connection.send_command(*args)

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/connection.py in get_connection(self, command_name, *keys, **options)
    992         try:
    993             # ensure this connection is connected to Redis
--> 994             connection.connect()
    995             # connections that the pool provides should be ready to send
    996             # a command. if not, the connection was either returned to the

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/connection.py in connect(self)
    498 
    499         self._sock = sock
--> 500         self._selector = DefaultSelector(sock)
    501         try:
    502             self.on_connect()

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/selector.py in DefaultSelector(sock)
    194         else:
    195             raise RedisError('Platform does not support any selectors')
--> 196     return _DEFAULT_SELECTOR(sock)

~/.local/share/virtualenvs/api-fKmI9ai6/lib/python3.6/site-packages/redis/selector.py in __init__(self, sock)
    122             super(PollSelector, self).__init__(sock)
    123             self.read_poller = select.poll()
--> 124             self.read_poller.register(sock, self._READ_POLLER_MASK)
    125             self.ready_poller = select.poll()
    126             self.ready_poller.register(sock, self._READY_POLLER_MASK)

TypeError: argument must be an int, or have a fileno() method.

Any idea of what is wrong?

@bmerry
Copy link
Collaborator

bmerry commented Feb 18, 2019

Some of that redis-py code looks new to me - I'm guessing you have a very new version of redis-py and that it's changed something that breaks the way fakeredis injects itself. Can you try downgrading to redis==3.0.1?

@bmerry bmerry changed the title TypeError: argument must be an int, or have a fileno() method. Does not work with redis-py 3.2 Feb 18, 2019
@bmerry
Copy link
Collaborator

bmerry commented Feb 18, 2019

I see the same error with redis-py 3.2. I'll make a 1.0.2 release just to put a redis<3.2 specifier in setup.py. Supporting redis-py 3.2 may take a while because it seems to have fundamentally changed how it deals with connections.

@MattBlack85
Copy link
Author

Works! Thanks

bmerry added a commit that referenced this issue Feb 18, 2019
redis-py 3.2 changes the way it interacts with sockets to use selectors,
which in turn requires a real socket. It will need some finesse to
support that in future.

See #235.
@jayvdb
Copy link

jayvdb commented Feb 19, 2019

Also encountering this at https://build.opensuse.org/package/show/home:jayvdb:django/python-fakeredis , and sadly I dont get to choose a lower version of python-redis , unless I create my own package instead of using the OS version.

@bmerry
Copy link
Collaborator

bmerry commented Mar 25, 2019

I've just released 1.0.3 which works with redis-py 3.2.

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

3 participants