On 29 September 2012 21:21,  <span dir="ltr">&lt;<a href="mailto:exarkun@twistedmatrix.com" target="_blank">exarkun@twistedmatrix.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 07:44 pm, <a href="mailto:poalman@gmail.com">poalman@gmail.com</a> wrote:<br>
&gt;<br>
&gt;Thank you. I&#39;ve made quite a bit of progress and now have my own<br>
&gt;Portal,<br>
&gt;CredentialsChecker, Realm, Shell, and FilePath object.<br>
&gt;<br>
&gt;One thing I haven&#39;t been able to work out is, when I override, lets say<br>
&gt;listdir for example in FilePath, I need to make a webcall to find out<br>
&gt;the<br>
&gt;folder contents, how can I make this call asynchronously?<br>
&gt;<br>
&gt;I&#39;m guessing I need to used deferred in someway, but seeing as listdir<br>
&gt;doesn&#39;t return deferred objects I&#39;m not sure how to make it work.<br>
&gt;<br>
&gt;As listdir gets called from the Shell I guess I could change how<br>
&gt;blocking<br>
&gt;calls in my FilePath object get called?<br>
<br>
</div>The place to customize listing the contents of a directory is in the<br>
shell.  More specifically, in an implementation of IFTPShell.list.  It&#39;s<br>
almost certainly the case that you should *not* have a FilePath subclass<br>
with overridden methods.  Instead, you should have a `list`<br>
implementation on your shell that returns the desired results.  And<br>
since `IFTPShell.list` is allowed to return a Deferred, you no longer<br>
have a problem performing asynchronous operations.<br>
<br>
Jean-Paul<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div> That is likely a much better idea! Will I need to use some threading if I&#39;m making web calls then from list? Presumably if I don&#39;t the whole process will block while it&#39;s waiting for web responses?</div>
<div><br></div><div>I&#39;ve seen there is a deferToThread but I&#39;m not too sure how to use it, do I just need to return it?</div></div>