[Twisted-Python] dynamic FTP realm

Paul Wiseman poalman at gmail.com
Mon Oct 1 15:18:42 EDT 2012


On 1 October 2012 16:52, Itamar Turner-Trauring
<itamar at futurefoundries.com>wrote:

>
>
> On Mon, Oct 1, 2012 at 5:38 AM, Paul Wiseman <poalman at gmail.com> wrote:
>
>>
>> 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?
>>
>
> Agent could certainly deal with this; alternatively, if you're using a
> blocking API you could use deferToThread (make sure the function you call
> that way doesn't touch any global state or call any Twisted APIs.)
>
> --
> Itamar Turner-Trauring, Future Foundries LLC
> http://futurefoundries.com/ — Twisted consulting, training and support.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
This is twisting my brain slightly.

what if I have more than 1 blocking call to make in the list dir call?

One area that is especially confusing for me is where I have those blocking
webcalls in a recursive method.

Because the api needs a folder's unique id to return a folder list, if for
instance someone requests a file/folder 10 levels deep, the list dir will
need to walk up the path until it finds a cached node that it has an id
for, and then walk back down the path listing the folders using the api.

I read about chained deferreds and I think that might be the way to go but
I'm not sure how I'd chain them together as 1 webcall needs the id from its
parent folder they all need to be executed in a chain, but return down the
recursive method stack

Are there any examples of how I could make a recursive function with
deferreds?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20121001/3f9f880b/attachment.htm 


More information about the Twisted-Python mailing list