Execute Python callbacks of the type given by the input string
| 27 | |
| 28 | // Execute Python callbacks of the type given by the input string |
| 29 | void ExecutePythonCallback ( const std::string& name ) |
| 30 | { |
| 31 | if ( IsPythonCallbackInstalled(name) ) { |
| 32 | ABLASTR_PROFILE("warpx_py_" + name); |
| 33 | try { |
| 34 | warpx_callback_py_map[name](); |
| 35 | } catch (std::exception &e) { |
| 36 | std::cerr << "Python callback '" << name << "' failed!" << "\n"; |
| 37 | std::cerr << e.what() << "\n"; |
| 38 | std::exit(3); // note: NOT amrex::Abort(), to avoid hangs with MPI |
| 39 | |
| 40 | // future note: |
| 41 | // if we want to rethrow/raise exceptions from Python callbacks through here (C++) and |
| 42 | // back the managing Python interpreter, we first need to discard and clear |
| 43 | // out the Python error in py::error_already_set. Otherwise, MPI-runs will hang |
| 44 | // (and Python will be in continued error state). |
| 45 | // https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html#handling-unraisable-exceptions |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void ClearPythonCallback ( const std::string& name ) |
| 51 | { |
no test coverage detected