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

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Mar 25 18:45:06 EDT 2013


On 07:47 pm, itamar at futurefoundries.com wrote:
>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())

Not that `FilePath` is guaranteed to be thread-safe...

Jean-Paul
>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.



More information about the Twisted-Python mailing list