Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

blpop command still block program after timeout #209

Open
larvavral opened this issue Mar 9, 2019 · 0 comments
Open

blpop command still block program after timeout #209

larvavral opened this issue Mar 9, 2019 · 0 comments

Comments

@larvavral
Copy link

larvavral commented Mar 9, 2019

I try to use blpop with timeout parameter as the following code:

int main(int argc, char* argv[]) {
  cpp_redis::client client;
  RedisInfo redis_info;
  redis_info.address = "127.0.0.1";
  redis_info.port = 6379;

  // This function is just init a redis client.
  if (!common::InitRedisClient(&client, redis_info)) {
    cout << "Establish connection to redis failed" << endl;
    return 0;
  } else {
    cout << "Establish connection to redis succeed" << endl;
  }

  vector<string> keys;
  keys.push_back("test");
  client.blpop(keys, 1, [](cpp_redis::reply& reply) {
    cout << "Blpop response: " << reply.as_string() << endl;
  });
  client.sync_commit();

  cout << "Blpop timeout" << endl;

  return 0;
}

As my understanding, program should print "Blpop timeout" after 1s and there are no data push to test list. But program seem to be block and never end.
Is this expected behavior of blpop command with timeout?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant