Pass an exception from a python event through the event queue

back into python so we don't just silently ignore those errors

--HG--
extra : convert_revision : e2f5566a4681f1b8ea80af50071119118afa7d8a
This commit is contained in:
Nathan Binkert 2007-02-17 20:27:11 -08:00
parent 3cb2686828
commit 18e245ad0b
3 changed files with 13 additions and 3 deletions

View file

@ -31,6 +31,7 @@
#include <Python.h>
#include "python/swig/pyevent.hh"
#include "sim/async.hh"
PythonEvent::PythonEvent(PyObject *obj, Tick when, Priority priority)
: Event(&mainEventQueue, priority), object(obj)
@ -52,9 +53,9 @@ PythonEvent::~PythonEvent()
void
PythonEvent::process()
{
PyObject *result;
result = PyObject_CallMethod(object, "process", "");
PyObject *args = PyTuple_New(0);
PyObject *result = PyObject_Call(object, args, NULL);
Py_DECREF(args);
if (result) {
// Nothing to do just decrement the reference count
@ -62,5 +63,7 @@ PythonEvent::process()
} else {
// Somethign should be done to signal back to the main interpreter
// that there's been an exception.
async_event = true;
async_exception = true;
}
}

View file

@ -47,6 +47,7 @@ extern volatile bool async_dump; ///< Async request to dump stats.
extern volatile bool async_exit; ///< Async request to exit simulator.
extern volatile bool async_io; ///< Async I/O request (SIGIO).
extern volatile bool async_alarm; ///< Async alarm event (SIGALRM).
extern volatile bool async_exception; ///< Python exception.
//@}
#endif // __ASYNC_HH__

View file

@ -82,6 +82,7 @@ volatile bool async_dumpreset = false;
volatile bool async_exit = false;
volatile bool async_io = false;
volatile bool async_alarm = false;
volatile bool async_exception = false;
/// Stats signal handler.
void
@ -371,6 +372,11 @@ simulate(Tick num_cycles = MaxTick)
async_alarm = false;
pollQueue.service();
}
if (async_exception) {
async_exception = false;
return NULL;
}
}
}