multiget in python client hangs after timeout

Jeff Peck jeffp at
Tue Jan 21 13:54:56 EST 2014


We are using Riak's multiget function from the Python API, and we have noticed that our service would sometimes hang and need to be restarted. After some searching, we found that the cause was Riak's multiget function.

Consider the following simple example where we are using multiget to only get a single object and we are passing a timeout of 1 millisecond.

import riak, riak_pb

riak_client = riak.RiakClient(host='localhost,
                              pb_port=8087, protocol='pbc')

for n in range(0,10: 
    print riak_client.multiget([('test_bucket', '398eed5613da8d0918cd64b3cf1d44b2')], 
                               timeout=1) #ms

A RiakError is raised, but the script just hangs after that and can only be stopped with a signal 9:

Exception in thread riak.client.multiget-worker-0:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/", line 532, in __bootstrap_inner
  File "/usr/local/lib/python2.6/", line 484, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.6/site-packages/riak/client/", line 130, in _fetcher
  File "/usr/local/lib/python2.6/site-packages/riak/", line 206, in get
    return obj.reload(r=r, pr=pr, timeout=timeout)
  File "/usr/local/lib/python2.6/site-packages/riak/", line 307, in reload
    self.client.get(self, r=r, pr=pr, timeout=timeout)
  File "/usr/local/lib/python2.6/site-packages/riak/client/", line 127, in wrapper
    return self._with_retries(pool, thunk)
  File "/usr/local/lib/python2.6/site-packages/riak/client/", line 69, in _with_retries
    return fn(transport)
  File "/usr/local/lib/python2.6/site-packages/riak/client/", line 125, in thunk
    return fn(self, transport, *args, **kwargs)
  File "/usr/local/lib/python2.6/site-packages/riak/client/", line 315, in get
    return transport.get(robj, r=r, pr=pr, timeout=timeout)
  File "/usr/local/lib/python2.6/site-packages/riak/transports/pbc/", line 146, in get
  File "/usr/local/lib/python2.6/site-packages/riak/transports/pbc/", line 43, in _request
    return self._recv_msg(expect)
  File "/usr/local/lib/python2.6/site-packages/riak/transports/pbc/", line 55, in _recv_msg
    raise RiakError(err.errmsg)
RiakError: 'timeout'

We are not able to catch the exception because it occurs in a different thread. So, when this occurs, it renders our service unusable until a restart is issued.

I would like to know if anybody else has encountered this and if there are any known work-arounds or a patch for riak/client/ that will propagate the timeout exception so the main thread no longer waits for it to never return.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list