Sandboxed Python: memory limits?

David Bolen db3l.net at gmail.com
Thu Apr 7 20:36:36 CEST 2011


Chris Angelico <rosuav at gmail.com> writes:

>                    So I'm hoping to restrict the script's ability to
> consume all of memory, without (preferably) ulimit/rlimiting the
> entire process (which does other things as well). But if it can't be,
> it can't be.

Just wondering, but rather than spending the energy to cap Python's
allocations internally, could similar effort instead be directed at
separating the "other things" the same process is doing?  How tightly
coupled is it?  If you could split off just the piece you need to
limit into its own process, then you get all the OS tools at your
disposal to restrict the resources of that process.

Depending on what the "other" things are, it might not be too hard to
split apart, even if you have to utilize some IPC mechanism to
coordinate among the two pieces.  Certainly might be of the same order
of magnitude of tweaking Python to limit memory internally.

-- David



More information about the Python-list mailing list