[Python-Dev] doc for new restricted execution design for Python

Brett Cannon brett at python.org
Wed Jun 28 18:50:42 CEST 2006


On 6/27/06, Neal Norwitz <nnorwitz at gmail.com> wrote:
>
> On 6/27/06, Brett Cannon <brett at python.org> wrote:
> >
> > > (5)  I think file creation/writing should be capped rather than
> > > binary; it is reasonable to say "You can create a single temp file up
> > > to 4K" or "You can create files, but not more than 20Meg total".
> >
> > That has been suggested before.  Anyone else like this idea?
>
> What would this code do:
>
>     MAX = 4
>     for i in xrange(10):
>       fp = open(str(i), 'w+')
>       fp.write(' ' * (MAX // 4))
>       fp.close()
>       if i % 2:
>           os.unlink(str(i))


 First of all, it would require that the file names have been cleared for
writing.  Otherwise an exception will be thrown the first time open() is
called.  Second, the os.unlink() will fail unless you whitelist your
platform's OS-specific module that is used by 'os' (e.g., posix).

How many times should this execute, 4 or 8?  What about if there is no
> if i % 2 and the file is unlinked at the end of each loop?  Should
> that loop 10 times without error?  What would happen if we used the
> same file name?  What would happen if we did something like:
>
>     fp = open(str(i), 'w+')
>     MAX = 4
>     for i in xrange(10000):
>       fp.seek(0)
>       fp.write(' ' * (MAX // 4))
>
> Should this succeed?


 If I put in any cap, I would make it universal for *all* disk writes (and
probably do the same for network sends).

-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060628/2c4589c5/attachment.htm 


More information about the Python-Dev mailing list