Skip to content

Commit

Permalink
Don't write out debug messages on shutdown
Browse files Browse the repository at this point in the history
When the python intrpreter exits, any attempts to log messages into it throw an exception.
Rather than writing these spurious error messages out, just write out the log message
using the default stderrlogger (if it's not a debug message).
  • Loading branch information
Ben Frederickson committed Aug 5, 2018
1 parent 727648b commit 870ba57
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python_bindings/nmslib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,12 @@ class PythonLogger
inner.attr("critical")(message);
break;
}
} catch (const std::exception & e) {
std::cerr << "Failed to log '" << message << "'. Exception:" << e.what() << std::endl;
} catch (...) {
std::cerr << "Failed to log '" << message << "'" << std::endl;
// This is almost certainly due to python process shut down.
// Just write the message out to stderr if its not a debug message
if (severity != LIB_DEBUG) {
StdErrLogger().log(severity, file, line, function, message);
}
}
}
};
Expand Down

0 comments on commit 870ba57

Please sign in to comment.