exec code with timeout?
Alex Martelli
aleax at aleax.it
Mon Sep 8 08:51:17 EDT 2003
John J. Lee wrote:
> Alex Martelli <aleax at aleax.it> writes:
>> Graham Fawcett wrote:
> [...]
>> > Hmm... well, again I'd suggest the PyThreadState_SetAsyncExc function.
>> > It shouldn't be that hard to wrap... I'd try it myself, but haven't
>> > made it
>> > to 2.3 yet. :(
>>
>> Nope -- the attacking script can easily use try/except to defeat attempts
>> to kill it via PyThreadState_SetAsyncExc . The latter isn't meant for
>> any "adversarial" situation, but just for potentially _buggy_ threads.
> [...]
>
> Which is what the OP asked for, actually -- the users are trusted.
I think you're right -- I had not understood the OP's specs correctly.
In this case, the OP's application seems to be exactly THE typical
use case for the new functionality (which has been kept in C only to
avoid attracting _inappropriate_ use...). See my lightning talk at
OSCON, slides at http://www.strakt.com/docs/os03_threads_interrupt.pdf ,
for a brief explanations of the how's & why and C source code to
wrap the new call if you KNOW it's exactly what you need.
Alex
More information about the Python-list
mailing list