Skip to content

Commit

Permalink
Check for exceptions prior to the liveness of the thread
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Aug 29, 2024
1 parent 4dbef0d commit 14d19c7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/mrc/_pymrc/src/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,19 @@ class PyIteratorWrapper
{
if (py_except.matches(m_empty_exception))
{
// Check to see if we got an exception
if (!m_exception_queue.attr("empty")().cast<bool>())
{
auto py_err_str = m_exception_queue.attr("get")("block"_a = true, "timeout"_a = 0.5);
throw std::runtime_error(py_err_str.cast<std::string>());
}

if (!m_thread.attr("is_alive")().cast<bool>())
{
// Check to see if we got an exception
if (!m_exception_queue.attr("empty")().cast<bool>())
{
auto py_err_str = m_exception_queue.attr("get")("block"_a = true, "timeout"_a = 0.5);
throw std::runtime_error(py_err_str.cast<std::string>());
}
throw pybind11::stop_iteration();
}

// if the thread is alive and we don't have an exception, just signal that we don't have any data
throw EmptyQueue();
}

Expand Down

0 comments on commit 14d19c7

Please sign in to comment.