]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ActivePyModules: do not touch PyFormatter without the GIL
authorSage Weil <sage@redhat.com>
Thu, 14 Feb 2019 13:24:09 +0000 (07:24 -0600)
committerSage Weil <sage@redhat.com>
Fri, 15 Feb 2019 13:10:22 +0000 (07:10 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/ActivePyModules.cc

index 984cf04b5f3537e6e4b25b985203e76103ae6c6a..dca77dc60398bbb90384ab235111019968e514d8 100644 (file)
@@ -104,10 +104,10 @@ PyObject *ActivePyModules::get_server_python(const std::string &hostname)
 
 PyObject *ActivePyModules::list_servers_python()
 {
+  PyFormatter f(false, true);
   PyThreadState *tstate = PyEval_SaveThread();
   dout(10) << " >" << dendl;
 
-  PyFormatter f(false, true);
   daemon_state.with_daemons_by_server([this, &f, &tstate]
       (const std::map<std::string, DaemonStateCollection> &all) {
     PyEval_RestoreThread(tstate);
@@ -299,10 +299,10 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     );
     return f.get();
   } else if (what == "devices") {
-    f.open_array_section("devices");
     daemon_state.with_devices2(
-      [&tstate]() {
+      [&tstate, &f]() {
        PyEval_RestoreThread(tstate);
+       f.open_array_section("devices");
       },
       [&f] (const DeviceState& dev) {
        f.dump_object("device", dev);