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

blpop command still block program after timeout #209

@larvavral

Description

@larvavral

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions