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

Christopher Tavares christophertavares at earthlink.net
Wed Jan 17 22:35:58 EST 2001


<rturpin at my-deja.com> wrote in message news:944n1v$8t6$1 at nnrp1.deja.com...
[... snip ...]
>
> 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

This is just an idea, but the Python debugging interface includes hooks for
trace functions. These get called every function or every line. That'd let
you get in there and do all sorts of stuff.

It'd probably kill your performance, though.

-Chris






More information about the Python-list mailing list