[Twisted-Python] The twisted way for basic file i/o?

glyph at divmod.com glyph at divmod.com
Wed Jun 18 01:45:03 EDT 2008

On 01:33 am, nathan.stocks at gmail.com wrote:
>I just want to do some basic text-file manipulations without blocking
>the rest of twisted.
>I've found "FilePath", which has an open()...which is undocumented:
>Is that what I should be using???

Yes and no.

Yes, you should use it, FilePath is great.

No, it won't solve your problem.  The APIs in FilePath will just block.

Asynchronous file I/O is a thorny problem, and Twisted doesn't have a 
canned solution for it.

The quick answer is "do it in a subprocess or a thread".

I'll save you time on the long answer, since it's a meandering 
exploration of a dozen platform-specific half-broken under- or un- 
documented APIs, that ends with "Oh, I guess you have to do it in a 
subprocess or a thread."

Hope that helps :).

More information about the Twisted-Python mailing list