
On 30 September 2012 13:59, Itamar Turner-Trauring < itamar@futurefoundries.com> wrote:
On Sun, Sep 30, 2012 at 8:38 AM, Paul Wiseman <poalman@gmail.com> wrote:
That is likely a much better idea! Will I need to use some threading if I'm making web calls then from list? Presumably if I don't the whole process will block while it's waiting for web responses?
If you're using Twisted's web clients (getPage or the more complex but superior Agent) you do not need threads, Twisted will do the networking in a non-blocking manner. E.g.
def list(self, path): return twisted.web.client.getPage(...).addCallback(convertHTTPResponseToFTPListing)
-- Itamar Turner-Trauring, Future Foundries LLC http://futurefoundries.com/ — Twisted consulting, training and support.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
I made an api for the web requests- the call isn't so straightforward, all the information is sent in POST formatted a certain way and there's also a credentials part with a token and other bits with secrets used to auth the request. So for instance I call the list dir method in the api and get back a Response type object based on the web response. Is there still way I can defer the returning of that web call, or would I need to tear the api apart to use twisted deferred objects internally? or is this something Agent could deal with?