Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OK here's my horrible workaround using rob hooft's task.py:

Write my matrix to a text-file. Put the charpoly calculation in a separate file called charpoly.sage which reads in the matrix from that text-file, and outputs its result to another text-file. Then in the main code run the following:

  from os import system
  load task.py
  maxtime = 3600
  success = 0 
  while success == 0:
     task = Task("sage charpoly.sage")
     task.Run()
     time = 0
     while time <= maxtime:
        sleep(1)
        time += 1
        if task.Done() == 1:
           success = 1
           task.Kill()
           break

     if time > maxtime:
        task.Kill()
        system("PIDS=$(ps -ef| grep -e 'python charpoly.py' | grep -v grep |awk '{print $2}')")
        system("kill -9 $PIDS")
        print ("timeout!")

That last business is because sage spawns some other python processes which eat up all the cpu and are not killed by task.Kill(). It's not pretty but it'll do the trick for now.

OK here's my horrible workaround using rob hooft's task.py:

Write my matrix to a text-file. Put the charpoly calculation in a separate file called charpoly.sage which reads in the matrix from that text-file, and outputs its result to another text-file. Then in the main code run the following:

  from os import system
  load task.py
  maxtime = 3600
  success = 0 
  while success == 0:
     task = Task("sage charpoly.sage")
     task.Run()
     time = 0
     while time <= maxtime:
        sleep(1)
        time += 1
        if task.Done() == 1:
           success = 1
           task.Kill()
           break

     if time > maxtime:
        task.Kill()
        system("PIDS=$(ps -ef| grep -e 'python charpoly.py' | grep -v grep |awk '{print $2}')")
        system("kill -9 $PIDS")
        print ("timeout!")

That last business is because sage spawns some other python processes which eat up all the cpu and are not killed by task.Kill(). It's not pretty but it'll do the trick for now.now. The reason that I simply restart the calculation after a timeout is that it only sporadically gets stuck, and restarting seems to get it going again, go figure...

OK here's my horrible workaround using rob hooft's task.py:

Write my matrix to a text-file. Put the charpoly calculation in a separate file called charpoly.sage which reads in the matrix from that text-file, and outputs its result to another text-file. Then in the main code run the following:

  from os import system
  load task.py
  maxtime = 3600
  success = 0 
  while success == 0:
     task = Task("sage charpoly.sage")
     task.Run()
     time = 0
     while time <= maxtime:
        sleep(1)
        time += 1
        if task.Done() == 1:
           success = 1
           task.Kill()
           break

     if time > maxtime:
        task.Kill()
        system("PIDS=$(ps -ef| grep -e 'python charpoly.py' | grep -v grep |awk '{print $2}')")
        system("kill -9 $PIDS")
        print ("timeout!")

That last business is because sage spawns some other python processes which eat up all the cpu and are not killed by task.Kill(). It's not pretty but it'll do the trick for now. The reason that I simply restart the calculation after a timeout is that it only sporadically gets stuck, and restarting seems to get it going again, go figure...

OK here's my horrible workaround using rob hooft's task.py:

Write my matrix to a text-file. Put the charpoly calculation in a separate file called charpoly.sage which reads in the matrix from that text-file, and outputs its result to another text-file. Then in the main code run the following:

  from os import system
  load task.py
  maxtime = 3600
  success = 0 
  while success == 0:
     task = Task("sage charpoly.sage")
     task.Run()
     time = 0
     while time <= maxtime:
        sleep(1)
        time += 1
        if task.Done() == 1:
           success = 1
           break

     if time > maxtime:
        task.Kill()
        system("PIDS=$(ps -ef| grep -e 'python charpoly.py' | grep -v grep |awk '{print $2}')")
        system("kill -9 $PIDS")
        print ("timeout!")

That last business rubbish is because sage spawns some other python processes which eat up all the cpu and are not killed by task.Kill(). It's not pretty but it'll do the trick for now. The reason that I simply restart the calculation after a timeout is that it only sporadically gets stuck, and restarting seems to get it going again, go figure...