--- a/src/core/bindings/module_helpers.cc Fri Jul 08 12:47:21 2011 +0200 +++ a/src/core/bindings/module_helpers.cc Fri Jul 08 12:47:54 2011 +0200 @@ -59,6 +59,31 @@ } }; +class CheckSignalEventImpl : public ns3::EventImpl +{ +public: + CheckSignalEventImpl () + { + } + virtual ~CheckSignalEventImpl () + { + } + virtual void Notify () + { + PyGILState_STATE __py_gil_state; + __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); + + PyErr_CheckSignals(); + if (PyErr_Occurred()) + ns3::Simulator::Stop(); + else + ns3::Simulator::Schedule(ns3::Seconds(1), this); + + if (PyEval_ThreadsInitialized()) + PyGILState_Release(__py_gil_state); + } +}; + PyObject * _wrap_Simulator_Schedule (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, @@ -310,11 +335,16 @@ if (signal_check_frequency == -1) { + ns3::Ptr py_event_impl = + ns3::Create(); if (PyEval_ThreadsInitialized ()) py_thread_state = PyEval_SaveThread (); + ns3::Simulator::Schedule(ns3::Seconds(1), py_event_impl); ns3::Simulator::Run (); if (py_thread_state) PyEval_RestoreThread (py_thread_state); + if (PyErr_Occurred()) + return NULL; } else { while (!ns3::Simulator::IsFinished ()) {