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: Command # 1 (ZADD unittesting_leaderboard (-: (DEFAULT: ), 32000) 1) of pipeline caused error: value is not a double #17

Closed
LaundroMat opened this issue Jan 22, 2014 · 9 comments

Comments

@LaundroMat
Copy link

Hi, I'm seeing this error log when calling rank_member on an existing member.

I should mention this is when running unit tests on a dev machine.

The values instance.user.id and instance.score evaluate to 2 and 0 respectively (both int).

Traceback (most recent call last):
...
  File "<removed>", line 43, in update_leaderboard
    lb.rank_member(instance.user.id, instance.score)
  File "C:\<removed>\site-packages\leaderboard\__init__.py", line 92, in rank_member
    self.rank_member_in(self.leaderboard_name, member, score, member_data)
  File "C:\<removed>\site-packages\leaderboard\__init__.py", line 106, in rank_member_in
    pipeline.execute()
  File "C:\<removed>\site-packages\redis\client.py", line 2154, in execute
    return execute(conn, stack, raise_on_error)
  File "C:\<removed>\site-packages\redis\client.py", line 2069, in _execute_transaction
    self.raise_first_error(commands, response)
  File "C:\<removed>\site-packages\redis\client.py", line 2105, in raise_first_error
    raise r
ResponseError: Command # 1 (ZADD unittesting_leaderboard (-: (DEFAULT: ), 32000) 1) of pipeline caused error: value is not a double

I tried the same command from within the shell (on the same database), and no error occurs. What might be the cause?

Thanks in advance,

@awestendorf
Copy link
Member

Are you using an older version of redis-py? redis/redis-py#70

@czarneckid
Copy link
Member

I think you're using a StrictRedis connection, not a Redis connection. I was able to reproduce a similar error by changing this line, https://github.com/agoragames/leaderboard-python/blob/master/leaderboard/__init__.py#L67, to use StrictRedis. I can look at identifying type of connection class and acting accordingly, but using Redis class should fix your issue.

>>> from leaderboard import Leaderboard
>>> highscore_lb = Leaderboard('highscores')
>>> highscore_lb.leaders(1)
[]
>>> highscore_lb.rank_member('david', 5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "leaderboard/__init__.py", line 92, in rank_member
    self.rank_member_in(self.leaderboard_name, member, score, member_data)
  File "leaderboard/__init__.py", line 106, in rank_member_in
    pipeline.execute()
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 1801, in execute
    return execute(conn, stack, raise_on_error)
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 1732, in _execute_transaction
    self.raise_first_error(response)
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 1760, in raise_first_error
    raise r
redis.exceptions.ResponseError: value is not a valid float

@LaundroMat
Copy link
Author

I'm sorry, but I cannot find any reference to StrictRedis (or Redis in fact) in my code; I'm now wondering how I'm actually making the connection at all (heh).

I uninstalled leaderboard and reinstalled it with pip install git+git://github.com/agoragames/leaderboard-python.git@master but I'm still seeing the same error.

@LaundroMat
Copy link
Author

@awestendorf I'm not using redis-py, the only redis related package installed is redis (2.9.0).

@czarneckid
Copy link
Member

The only way I can reproduce a similar error to you is to:

  1. Back out the commit above from master
  2. Use redis 2.9.0 library
  3. Change the initializer to use self.redis_connection = StrictRedis(**self.options) instead of self.redis_connection = Redis(**self.options)

Running the tests I'll see:

======================================================================
ERROR: test_total_pages (test.leaderboard.leaderboard_test.LeaderboardTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dczarnecki/projects/leaderboard-python/test/leaderboard/leaderboard_test.py", line 83, in test_total_pages
    self.__rank_members_in_leaderboard(27)
  File "/Users/dczarnecki/projects/leaderboard-python/test/leaderboard/leaderboard_test.py", line 433, in __rank_members_in_leaderboard
    self.leaderboard.rank_member('member_%s' % index, index, { 'member_name': 'Leaderboard member %s' % index })
  File "/Users/dczarnecki/projects/leaderboard-python/leaderboard/__init__.py", line 92, in rank_member
    self.rank_member_in(self.leaderboard_name, member, score, member_data)
  File "/Users/dczarnecki/projects/leaderboard-python/leaderboard/__init__.py", line 106, in rank_member_in
    pipeline.execute()
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 2154, in execute
    return execute(conn, stack, raise_on_error)
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 2069, in _execute_transaction
    self.raise_first_error(commands, response)
  File "/Users/dczarnecki/.virtualenvs/leaderboard-python/lib/python2.7/site-packages/redis/client.py", line 2105, in raise_first_error
    raise r
ResponseError: Command # 1 (ZADD name member_1 1) of pipeline caused error: value is not a valid float

Also running Redis 2.8.3 here, but pretty sure it's because of StrictRedis vs. Redis above. Without any override, the library connects to Redis on localhost:6379/0.

@LaundroMat
Copy link
Author

Allright, the issue can be closed. Thanks for your replies @awestendorf and @czarneckid - as always it's a problem I created myself. Django ExpressionNodes were not being evaluated before storing them (I printed them out before testing their type in the initial tests).

@ShipraShalini
Copy link

Hi,
I am getting the same error while using rank_members function.
Here is my code snippet:

score_name_list1 [[u'member1', 130], [u'member2', 130], [u'member3', 98], [u'member4', 190]
leaderboard = Leaderboard('_global')
leaderboard.rank_members(fb_score_name_list1)

ResponseError: Command # 1 (ZADD _global [u'member1', 130], [u'member2', 130]) of pipeline caused error: value is not a double

Can you help me with this??

@czarneckid
Copy link
Member

@ShipraShalini See correct usage of rank_members function in the tests,

def test_rank_members(self):
self.leaderboard.total_members().should.equal(0)
self.leaderboard.rank_members(['member_1', 1000, 'member_2', 3000])
self.leaderboard.total_members().should.equal(2)

@ShipraShalini
Copy link

@czarneckid Can I also insert member_data with rank_members?

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

4 participants