@@ -26,7 +26,10 @@ void PyThreadPoller::init_common(const std::string& name) {
2626}
2727
2828void PyThreadPoller::set_is_polling (bool is_polling) {
29- if (is_polling == m_is_polling) return ;
29+ if (is_polling == m_is_polling) {
30+ std::cout << " Already set " << is_polling << std::endl;
31+ return ;
32+ }
3033 m_is_polling = is_polling;
3134
3235 if (m_is_polling) {
@@ -46,12 +49,17 @@ void PyThreadPoller::set_period_in_ms(uint64_t period_ms) {
4649}
4750
4851void PyThreadPoller::run_poll_loop () {
49- if (m_poll_loop_running) return ; // only run one loop at a time
52+ if (m_poll_loop_running) {
53+ std::cout << " PyThreadPoller::run_poll_loop(): already running loop" << std::endl;
54+ return ; // only run one loop at a time
55+ }
5056 m_poll_loop_running = true ;
5157
5258 // start pool loop thread
5359 // TODO: use global threadpool, background sync wasm wallet in c++ thread
60+ std::cout << " Initializing thread..." << std::endl;
5461 m_thread = boost::thread ([this ]() {
62+ std::cout << " Started thread" << std::endl;
5563
5664 // poll while enabled
5765 while (m_is_polling) {
@@ -67,8 +75,11 @@ void PyThreadPoller::run_poll_loop() {
6775 }
6876 }
6977
78+ std::cout << " End thread" << std::endl;
7079 m_poll_loop_running = false ;
7180 });
81+ std::cout << " Initialized thread" << std::endl;
82+
7283}
7384
7485py::object PyGenUtils::convert_value (const std::string& val) {
@@ -753,8 +764,10 @@ void PyMoneroConnectionManager::stop_polling() {
753764}
754765
755766void PyMoneroConnectionManager::start_polling (const boost::optional<uint64_t >& period_ms, const boost::optional<bool >& auto_switch, const boost::optional<uint64_t >& timeout_ms, const boost::optional<PyMoneroConnectionPollType>& poll_type, const boost::optional<std::vector<std::shared_ptr<PyMoneroRpcConnection>>> &excluded_connections) {
767+ std::cout << " PyMoneroConnectionManager::start_polling()" << std::endl;
756768 // stop polling
757769 stop_polling ();
770+ std::cout << " PyMoneroConnectionManager::start_polling(): stopped polling" << std::endl;
758771
759772 // apply defaults
760773 uint64_t poll_period_ms = period_ms == boost::none ? DEFAULT_POLL_PERIOD : period_ms.get ();
@@ -770,7 +783,9 @@ void PyMoneroConnectionManager::start_polling(const boost::optional<uint64_t>& p
770783 }
771784
772785 // start polling
786+ std::cout << " PyMoneroConnectionManager::start_polling(): set polling..." << std::endl;
773787 set_is_polling (true );
788+ std::cout << " PyMoneroConnectionManager::start_polling(): set polling: " << m_is_polling << std::endl;
774789}
775790
776791std::shared_ptr<PyMoneroRpcConnection> PyMoneroConnectionManager::get_best_available_connection (const std::set<std::shared_ptr<PyMoneroRpcConnection>>& excluded_connections) {
@@ -908,6 +923,7 @@ std::vector<std::vector<std::shared_ptr<PyMoneroRpcConnection>>> PyMoneroConnect
908923
909924void PyMoneroConnectionManager::poll () {
910925 // do polling
926+ std::cout << " PyMoneroConnectionManager::poll()" << std::endl;
911927 switch (m_poll_type) {
912928 case PyMoneroConnectionPollType::CURRENT:
913929 check_connection ();
@@ -927,6 +943,7 @@ bool PyMoneroConnectionManager::check_connections(const std::vector<std::shared_
927943 try {
928944 // start checking connections in parallel
929945 boost::asio::thread_pool pool (4 );
946+ std::cout << " PyMoneroConnectionManager::check_connections(): initiliazed thread pool" << std::endl;
930947 boost::mutex result_mutex;
931948 boost::condition_variable result_cv;
932949 std::vector<std::shared_ptr<PyMoneroRpcConnection>> completed;
@@ -939,9 +956,11 @@ bool PyMoneroConnectionManager::check_connections(const std::vector<std::shared_
939956 num_tasks++;
940957
941958 boost::asio::post (pool, [this , connection, &result_mutex, &result_cv, &completed]() {
959+ std::cout << " checking connection: " << connection->serialize () << std::endl;
942960 bool change = connection->check_connection (m_timeout);
943961
944962 if (change && connection == get_connection ()) {
963+ std::cout << " changed connection: " << connection->serialize () << std::endl;
945964 on_connection_changed (connection);
946965 }
947966
@@ -960,9 +979,11 @@ bool PyMoneroConnectionManager::check_connections(const std::vector<std::shared_
960979 // wait for responses
961980 while (received < num_tasks) {
962981 boost::unique_lock<boost::mutex> lock (result_mutex);
982+ std::cout << " Waiting for connection..." << std::endl;
963983 result_cv.wait (lock, [&]() { return completed.size () > received; });
964984
965985 auto connection = completed[received++];
986+ std::cout << " Got connection: " << connection->serialize () << std::endl;
966987 lock.unlock ();
967988
968989 if (connection->is_connected ().value_or (false ) && !has_connection) {
0 commit comments