- Catch UserInterruptException launched from

PythonPolicy in Scheduler, but it cheerfully 
segfaults python...


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@464 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-02-26 23:38:25 +00:00
parent 8c39173c2f
commit 0a6b34d6ab
3 changed files with 112 additions and 85 deletions

View file

@ -156,12 +156,13 @@ PythonPolicy::get_time_slice() const throw(UserInterruptException) {
void
PythonPolicy::wait_unlock() const throw(UserInterruptException)
{
PyThreadState *_save;
PyThreadState* _save;
int i = 0; // We give the sort_queue() three seconds max time, then...
// we shot it stone dead! Bang.
bool still_locked;
do {
do
{
Py_UNBLOCK_THREADS;
usleep(25000); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
Py_BLOCK_THREADS;
@ -171,9 +172,12 @@ PythonPolicy::wait_unlock() const throw(UserInterruptException)
Py_DECREF(retval);
if(i++ > 120)
{
throw UserInterruptException("User-defined policy is "
"taking too long to terminate.");
} while(still_locked);
}
}
while(still_locked);
// What we should really do here: