MCPcopy Create free account
hub / github.com/BLAST-WarpX/warpx / ExecutePythonCallback

Function ExecutePythonCallback

Source/Python/callbacks.cpp:29–48  ·  view source on GitHub ↗

Execute Python callbacks of the type given by the input string

Source from the content-addressed store, hash-verified

27
28// Execute Python callbacks of the type given by the input string
29void 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
50void ClearPythonCallback ( const std::string& name )
51{

Callers 11

EvolveMethod · 0.85
OneStepMethod · 0.85
OneStep_nosubMethod · 0.85
HandleSignalsMethod · 0.85
EvolveBMethod · 0.85
EvolveEMethod · 0.85
HybridPICSolveEMethod · 0.85
InitDataMethod · 0.85
LoadExternalFieldsMethod · 0.85

Calls 1

Tested by

no test coverage detected