| 213 | static std::unordered_map<int64_t, std::set<pid_t>> worker_pids = {}; |
| 214 | |
| 215 | static void check_any_worker_failed() { |
| 216 | int error; |
| 217 | std::set<pid_t>* pid_set; |
| 218 | pid_t worker_pid; |
| 219 | siginfo_t infop; |
| 220 | |
| 221 | for (auto& w : worker_pids) { |
| 222 | pid_set = &(w.second); |
| 223 | for (auto pid_it = pid_set->begin(); pid_it != pid_set->end(); ++pid_it) { |
| 224 | worker_pid = *pid_it; |
| 225 | infop.si_pid = 0; |
| 226 | error = waitid(P_PID, worker_pid, &infop, WEXITED | WNOHANG | WNOWAIT); |
| 227 | if (error < 0 || infop.si_pid == 0) |
| 228 | continue; |
| 229 | if (infop.si_code == CLD_EXITED && |
| 230 | infop.si_status != EXIT_SUCCESS) { // exit with error |
| 231 | std::ostringstream oss; |
| 232 | oss << "DataLoader worker (pid " << worker_pid << ") exited " |
| 233 | << "unexpectedly with exit code " << infop.si_status << ". "; |
| 234 | pid_set->clear(); |
| 235 | throw std::runtime_error(oss.str()); |
| 236 | } else if ( |
| 237 | infop.si_code == CLD_KILLED || |
| 238 | infop.si_code == CLD_DUMPED) { // killed by signal |
| 239 | std::ostringstream oss; |
| 240 | oss << "DataLoader worker (pid " << worker_pid << ") is killed " |
| 241 | << "by signal: " << strsignal(infop.si_status) << ". " |
| 242 | << "This error maybe casued by other libraries is not supported " |
| 243 | << "well in mutiprocessing(fork), e.g. grpcio this python library. " |
| 244 | << "Please check grpcio version and try to a lower version like " |
| 245 | "1.47.0. If grpcio version is suitable, please check your " |
| 246 | "environment."; |
| 247 | pid_set->clear(); |
| 248 | throw std::runtime_error(oss.str()); |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | inline int64_t unpackLong(PyObject* obj) { |
| 255 | int overflow; |
no test coverage detected