Any way to restrict execution with regard to execution time??

rturpin at my-deja.com rturpin at my-deja.com
Wed Jan 17 13:08:07 EST 2001


The restricted execution module let's you run untrusted code
in a fashion that gives it only guarded access to the file
system, operating system services, and other important
resources. However, it provides no guard for the most important
resource: execution time. The moment untrusted code is
invoked by r_exec, it can go into an infinite loop.

The natural way to deal with this is to put the guarded
execution in one thread, and have a second thread that
serves to time-out the first thread. But there is no way
for one thread to kill another thread, so that's no help.

So here's the problem, that seems intractable in Python.
There are two pieces of code, C1 and C2. C1 wants to run
C2, but does not trust it to consume only a reasonable
amount of time (measured in any fashion). How can C1 run
C2 guaranteeing that C2's execution is interrupted after
some finite amount of time, if it hasn't finished by
then? C2 is from an untrusted source, so the answer
cannot be phrased in terms of how C2 is written. I'd be
much obliged to anyone who can tell me how to do this!

Russell


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list