| 40 | } |
| 41 | |
| 42 | virtual Sample next() const { |
| 43 | Sample sample; |
| 44 | { |
| 45 | std::unique_lock lock(mutex_); |
| 46 | py::gil_scoped_acquire gil; |
| 47 | try { |
| 48 | sample = mlx::pybind::to_sample(next_().cast<py::dict>()); |
| 49 | } catch (py::error_already_set& e) { |
| 50 | if (e.matches(PyExc_StopIteration)) { |
| 51 | // do nothing |
| 52 | } else { |
| 53 | throw; |
| 54 | } |
| 55 | } catch (...) { |
| 56 | throw; |
| 57 | } |
| 58 | } |
| 59 | return sample; |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | py::function iterable_factory_; |
no test coverage detected