0

I have a python based application and it calls the below .cpp code through pythonBinding.

while(1) {
      auto statusResponse = _mProxy->GetStatusAsync(
          nodeKey, std::bind(&NodeIfaceImpl::getStatusDbusCallback, this,
                             std::placeholders::_1, std::placeholders::_2));
      std::future_status statusCode =statusResponse.wait_for(std::chrono::milliseconds(5000));
      switch (statusCode) {
        case std::future_status::deferred:
          std::cout << "deferred" << std::endl;
          continue;
        case std::future_status::timeout:
          std::cout << "timeout" << std::endl;
          continue;
        case std::future_status::ready:
          std::cout << "ready" << std::endl;
          break;
      }
      if (!statusResponse.valid()) {
        SYSLOG_ERROR("Invalid Response received");
        continue;
      }
      auto callStatus = statusResponse.get();
      ....
      ....
}

the std::future waits for the message received from dbus. I can see that dbus is replying. but the std::future is going timeout sometimes not every time. if it goes for timeout once, it continuously goes for timeout even though dbus is replying the response.

I am using the same code in one more complete C++ application, there I do not see any problem. it works fine.

any thread related issues with pythonBinding and std::future ?

deepan muthusamy
  • 321
  • 2
  • 14

0 Answers0