Просмотр исходного кода

examples : flush log upon ctrl+c (#9559)

Georgi Gerganov 1 год назад
Родитель
Сommit
d39e26741f
2 измененных файлов с 10 добавлено и 0 удалено
  1. 5 0
      examples/infill/infill.cpp
  2. 5 0
      examples/main/main.cpp

+ 5 - 0
examples/infill/infill.cpp

@@ -97,6 +97,11 @@ static void sigint_handler(int signo) {
             LOG("\n");
             gpt_perf_print(*g_ctx, *g_smpl);
             write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens);
+
+            // make sure all logs are flushed
+            LOG("Interrupted by user\n");
+            gpt_log_pause(gpt_log_main());
+
             _exit(130);
         }
     }

+ 5 - 0
examples/main/main.cpp

@@ -116,6 +116,11 @@ static void sigint_handler(int signo) {
             LOG("\n");
             gpt_perf_print(*g_ctx, *g_smpl);
             write_logfile(*g_ctx, *g_params, *g_model, *g_input_tokens, g_output_ss->str(), *g_output_tokens);
+
+            // make sure all logs are flushed
+            LOG("Interrupted by user\n");
+            gpt_log_pause(gpt_log_main());
+
             _exit(130);
         }
     }