[Twisted-Python] So... Python 3.4 is getting its own async I/O system

Itamar Turner-Trauring itamar at futurefoundries.com
Mon Mar 25 15:47:52 EDT 2013


On Mon, Mar 25, 2013 at 11:59 AM, Peter Westlake
<peter.westlake at pobox.com>wrote:

> Understood that it isn't possible to use native asynchronous I/O. But an
> implementation that used threads behind the scenes and returned a
> Deferred (for small files) or a Protocol (for big ones) would be a nice
> thing to have.
>

For streaming files, you want something pausable; there are existing
producers which don't use threads, and there will presumably be a tubes
equivalent. Maybe having the tubes one use threads by default is a good
idea.

For getting a file as a string, you can just do:

d = deferToThread(lambda path: FilePath(path).getContent())

For more complex usage patterns, you'll probably want to write custom code
using deferToThread/deferToThreadPool anyway.

-- 
Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130325/9f797d5d/attachment.htm 


More information about the Twisted-Python mailing list