pinterest/pymemcache

TypeError when calling 'get_many' on HashClient with Unix socket location

bombedhair opened this issue · 1 comments

from pymemcache.client.hash import HashClient

client = HashClient(['/path/to/memcached.socket', ])
client.get_many(['ITEM_A', 'ITEM_B'])

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/path/to/venv/lib/python3.9/site-packages/pymemcache/client/hash.py", line 413, in get_many
    if gets:
TypeError: not enough arguments for format string

At line 409 of /pymemcache/client/hash.py

client = self.clients['%s:%s' % server]

Since server is a str of Unix socket location in this case, not the tuple that contains IP and PORT, TypeError: not enough arguments for format string happens when using get_many and set_many.

Should be like

if isinstance(server, six.string_types):
    client = self.clients[server]
else:
    client = self.clients['%s:%s' % server]

or restricting Unix Socket on HashClient if it's not likely to have multiple Unix sockets (I'm not sure about this)

@pope1ni do you have thoughts on the best way to handle this?