<br><br><div class="gmail_quote">On Mon, Mar 25, 2013 at 11:59 AM, Peter Westlake <span dir="ltr">&lt;<a href="mailto:peter.westlake@pobox.com" target="_blank">peter.westlake@pobox.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Understood that it isn&#39;t possible to use native asynchronous I/O. But an<br>
implementation that used threads behind the scenes and returned a<br>
Deferred (for small files) or a Protocol (for big ones) would be a nice<br>
thing to have.<br></blockquote><div><br></div><div>For streaming files, you want something pausable; there are existing producers which don&#39;t use threads, and there will presumably be a tubes equivalent. Maybe having the tubes one use threads by default is a good idea.</div>
<div><br></div><div>For getting a file as a string, you can just do:</div><div><br></div><div>d = deferToThread(lambda path: FilePath(path).getContent())</div><div><br></div><div>For more complex usage patterns, you&#39;ll probably want to write custom code using deferToThread/deferToThreadPool anyway.</div>
<div><br></div></div>-- <br>Itamar Turner-Trauring, Future Foundries LLC<br><a href="http://futurefoundries.com/" target="_blank">http://futurefoundries.com/</a> — Twisted consulting, training and support.<br>