Skip to content

Commit

Permalink
Merge pull request #325 from hahnjo/jupyter-hub-logging
Browse files Browse the repository at this point in the history
Silence logging when launched from Jupyter
  • Loading branch information
JohanMabille committed Apr 1, 2020
2 parents 133f7eb + 5f133cc commit 4ac5849
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ interpreter_ptr build_interpreter(int argc, char** argv)

int main(int argc, char* argv[])
{
// If we are called from the Jupyter launcher, silence all logging. This
// is important for a JupyterHub configured with cleanup_servers = False:
// Upon restart, spawned single-user servers keep running but without the
// std* streams. When a user then tries to start a new kernel, xeus-cling
// will get a SIGPIPE when writing to any of these and exit.
if (std::getenv("JPY_PARENT_PID") != NULL)
{
std::clog.setstate(std::ios_base::failbit);
}

std::string file_name = extract_filename(argc, argv);

interpreter_ptr interpreter = build_interpreter(argc, argv);
Expand Down

0 comments on commit 4ac5849

Please sign in to comment.