Thank you for your response.
As I told you, I have integral calculator. In general it is a hard problem.
When algoritm is executed, it goes through a list of integration rules.
Sometimes rules can be run infinitely and it is impossible to tell, whether
it is infinite execution. Like for integral sin(x)/(cos(x)+tan(x)) algo
uses a list of rules and each rule is followed by other rules etc.
So, I set a limit of time, using the following decorator:
def time_limit(timeout):
def internal(function):
def internal2(*args, **kw):
class Calculator(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.result = None
self.error = None
def run(self):
try:
self.result = function(*args, **kw)
except Exception as e:
self.error = e
def _stop(self):
if self.isAlive():
threading.Thread._Thread__stop(self)
c = Calculator()
c.start()
c.join(timeout)
if c.isAlive():
raise TimeoutException
if c.error:
raise c.error
return c.result
return internal2
return internal
It works good. I usually set limit 150 seconds. But it appears that memory
is used faster than time. Even time reduction to 45 seconds doesn't work.
So, I thought that maybe similar code can be written for memory management.
When memory is exceeded raise some Exception.
Though, I can't find any working example.
Maybe you can help me?
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.