[Python-Dev] Sandboxing Python

Victor Stinner victor.stinner at gmail.com
Mon Mar 5 10:09:40 CET 2012


>>> You can't solve the too much time, without solving the halting problem,
>>
>> Not sure what you mean by that.  It seems to me that it's particularly
>> easy to do in a roughly portable way, with alarm() for example on all
>> UNIXes.
>
> What time should you set the alarm for? How much time is enough before you
> decide that a piece of code is taking too long?

pysandbox uses SIGALRM with a timeout of 5 seconds by default. You can
change this timeout or disable it completly.

pysandbox doesn't provide a function to limit the memory yet, you have
to do it manually. It's not automatic because there is no portable way
to implement such limit and it's difficult to configure it. For my IRC
bot using pysandbox, setrlimit() is used with RLIMIT_AS.

Victor


More information about the Python-Dev mailing list