| 265 | } |
| 266 | |
| 267 | static void set_worker_pids(PyObject* id, PyObject* tuple_item) { |
| 268 | int64_t key = unpackLong(id); |
| 269 | if (worker_pids.find(key) != worker_pids.end()) { |
| 270 | throw std::runtime_error( |
| 271 | "_set_worker_pids should be called only once for each " |
| 272 | "DataLoaderIter."); |
| 273 | } |
| 274 | |
| 275 | if (!PyTuple_Check(tuple_item)) { |
| 276 | throw std::runtime_error("_set_worker_pids expects a tuple for child_pids"); |
| 277 | } |
| 278 | |
| 279 | std::set<pid_t> pids_set = {}; |
| 280 | auto size = PyTuple_GET_SIZE(tuple_item); |
| 281 | for (Py_ssize_t idx = 0; idx < size; ++idx) { |
| 282 | PyObject* obj = PyTuple_GET_ITEM(tuple_item, idx); |
| 283 | pids_set.insert(static_cast<pid_t>(unpackLong(obj))); |
| 284 | } |
| 285 | |
| 286 | worker_pids[key] = pids_set; |
| 287 | } |
| 288 | |
| 289 | static void reset_worker_pids(PyObject* loader_id) { |
| 290 | int64_t key = unpackLong(loader_id); |
no test coverage detected