<br><br><div><span class="gmail_quote">On 6/27/06, <b class="gmail_sendername">Neal Norwitz</b> &lt;<a href="mailto:nnorwitz@gmail.com">nnorwitz@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 6/27/06, Brett Cannon &lt;<a href="mailto:brett@python.org">brett@python.org</a>&gt; wrote:<br>&gt;<br>&gt; &gt; (5)&nbsp;&nbsp;I think file creation/writing should be capped rather than<br>&gt; &gt; binary; it is reasonable to say &quot;You can create a single temp file up
<br>&gt; &gt; to 4K&quot; or &quot;You can create files, but not more than 20Meg total&quot;.<br>&gt;<br>&gt; That has been suggested before.&nbsp;&nbsp;Anyone else like this idea?<br><br>What would this code do:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;MAX = 4
<br>&nbsp;&nbsp;&nbsp;&nbsp;for i in xrange(10):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fp = open(str(i), 'w+')<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fp.write(' ' * (MAX // 4))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fp.close()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if i % 2:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;os.unlink(str(i))</blockquote><div><br>&nbsp;First of all, it would require that the file names have been cleared for writing.&nbsp; Otherwise an exception will be thrown the first time open() is called.&nbsp; Second, the 
os.unlink() will fail unless you whitelist your platform's OS-specific module that is used by 'os' (e.g., posix).<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
How many times should this execute, 4 or 8?&nbsp;&nbsp;What about if there is no<br>if i % 2 and the file is unlinked at the end of each loop?&nbsp;&nbsp;Should<br>that loop 10 times without error?&nbsp;&nbsp;What would happen if we used the<br>same file name?&nbsp;&nbsp;What would happen if we did something like:
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;fp = open(str(i), 'w+')<br>&nbsp;&nbsp;&nbsp;&nbsp;MAX = 4<br>&nbsp;&nbsp;&nbsp;&nbsp;for i in xrange(10000):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fp.seek(0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fp.write(' ' * (MAX // 4))<br><br>Should this succeed?</blockquote><div><br>&nbsp;If I put in any cap, I would make it universal for *all* disk writes (and probably do the same for network sends).
<br><br>-Brett</div></div>