forked from mindspore-Ecosystem/mindspore
!6975 serving ctrl+c multi times exception fix
Merge pull request !6975 from 徐永飞/master
This commit is contained in:
commit
58e9efb8aa
|
@ -26,6 +26,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <atomic>
|
||||||
#include "include/infer_log.h"
|
#include "include/infer_log.h"
|
||||||
#include "serving/ms_service.grpc.pb.h"
|
#include "serving/ms_service.grpc.pb.h"
|
||||||
#include "core/util/option_parser.h"
|
#include "core/util/option_parser.h"
|
||||||
|
@ -43,10 +44,16 @@ namespace serving {
|
||||||
namespace {
|
namespace {
|
||||||
static const uint32_t uint32max = 0x7FFFFFFF;
|
static const uint32_t uint32max = 0x7FFFFFFF;
|
||||||
std::promise<void> exit_requested;
|
std::promise<void> exit_requested;
|
||||||
|
std::atomic_flag has_exited = ATOMIC_FLAG_INIT;
|
||||||
|
|
||||||
static const char kServerHttpIp[] = "0.0.0.0";
|
static const char kServerHttpIp[] = "0.0.0.0";
|
||||||
|
|
||||||
void ClearEnv() { Session::Instance().Clear(); }
|
void ClearEnv() { Session::Instance().Clear(); }
|
||||||
void HandleSignal(int sig) { exit_requested.set_value(); }
|
void HandleSignal(int sig) {
|
||||||
|
if (!has_exited.test_and_set()) {
|
||||||
|
exit_requested.set_value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
grpc::Status CreatGRPCStatus(const Status &status) {
|
grpc::Status CreatGRPCStatus(const Status &status) {
|
||||||
switch (status.StatusCode()) {
|
switch (status.StatusCode()) {
|
||||||
|
|
Loading…
Reference in New Issue