std::lock_guard l(lock);
const auto name = py_module->get_name();
- auto em = modules.emplace(name,
- std::make_shared<ActivePyModule>(py_module, clog));
- ceph_assert(em.second); // actually inserted
- auto& active_module = em.first->second;
+ auto active_module = std::make_shared<ActivePyModule>(py_module, clog);
+ pending_modules.insert(name);
// Send all python calls down a Finisher to avoid blocking
// C++ code, and avoid any potential lock cycles.
finisher.queue(new LambdaContext([this, active_module, name](int) {
int r = active_module->load(this);
+ std::lock_guard l(lock);
+ pending_modules.erase(name);
if (r != 0) {
derr << "Failed to run module in active mode ('" << name << "')"
<< dendl;
- std::lock_guard l(lock);
- modules.erase(name);
} else {
+ auto em = modules.emplace(name, active_module);
+ ceph_assert(em.second); // actually inserted
+
dout(4) << "Starting thread for " << name << dendl;
active_module->thread.create(active_module->get_thread_name());
}