
On 29 September 2012 21:21, <exarkun@twistedmatrix.com> wrote:
On 07:44 pm, poalman@gmail.com wrote:
Thank you. I've made quite a bit of progress and now have my own Portal, CredentialsChecker, Realm, Shell, and FilePath object.
One thing I haven't been able to work out is, when I override, lets say listdir for example in FilePath, I need to make a webcall to find out the folder contents, how can I make this call asynchronously?
I'm guessing I need to used deferred in someway, but seeing as listdir doesn't return deferred objects I'm not sure how to make it work.
As listdir gets called from the Shell I guess I could change how blocking calls in my FilePath object get called?
The place to customize listing the contents of a directory is in the shell. More specifically, in an implementation of IFTPShell.list. It's almost certainly the case that you should *not* have a FilePath subclass with overridden methods. Instead, you should have a `list` implementation on your shell that returns the desired results. And since `IFTPShell.list` is allowed to return a Deferred, you no longer have a problem performing asynchronous operations.
Jean-Paul
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? I've seen there is a deferToThread but I'm not too sure how to use it, do I just need to return it?