| 73 | } |
| 74 | |
| 75 | void StandbyPyModules::start_one(PyModuleRef py_module) |
| 76 | { |
| 77 | std::lock_guard l(lock); |
| 78 | const auto name = py_module->get_name(); |
| 79 | auto standby_module = new StandbyPyModule(state, py_module, clog); |
| 80 | |
| 81 | // Send all python calls down a Finisher to avoid blocking |
| 82 | // C++ code, and avoid any potential lock cycles. |
| 83 | finisher.queue(new LambdaContext([this, standby_module, name](int) { |
| 84 | int r = standby_module->load(); |
| 85 | if (r != 0) { |
| 86 | derr << "Failed to run module in standby mode ('" << name << "')" |
| 87 | << dendl; |
| 88 | delete standby_module; |
| 89 | } else { |
| 90 | std::lock_guard l(lock); |
| 91 | auto em = modules.emplace(name, standby_module); |
| 92 | ceph_assert(em.second); // actually inserted |
| 93 | |
| 94 | dout(4) << "Starting thread for " << name << dendl; |
| 95 | standby_module->thread.create(standby_module->get_thread_name()); |
| 96 | } |
| 97 | })); |
| 98 | } |
| 99 | |
| 100 | int StandbyPyModule::load() |
| 101 | { |