[Twisted-Python] The twisted way for basic file i/o?
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: http://twistedmatrix.com/documents/current/api/twisted.python.filepath.FileP... Is that what I should be using??? ~ Nathan
On 01:33 am, nathan.stocks@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:
http://twistedmatrix.com/documents/current/api/twisted.python.filepath.FileP...
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 :).
participants (2)
-
glyph@divmod.com -
Nathan