In twisted a polling loop usually translates into either a system of reactor.callLaters or a twisted.internet.task.LoopingCall.<br><br>Either like this this:<br><br>&nbsp;&nbsp;&nbsp; def __init__(self,oaf,interval=600):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.interval=interval<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.callLater(5,self.checkSystem)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def checkSystem(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.callLater(self.interval,self.checkSystem)<br><br>or like this:<br><br>&nbsp;&nbsp;&nbsp; def __init__(self,oaf,interval=600):<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.interval=interval<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
task.LoopingCall(self.checkSystem).start(self.interval)<br><br>When I wrote what may be a similar system I actually set it up to refresh only when a client requested the output and the local copy was out of date, so you may actually prefer that approach.<br>
<br>-Andy Fundinger<br><br><div class="gmail_quote">On Sun, Jan 4, 2009 at 9:52 PM, Robert Hancock <span dir="ltr">&lt;<a href="mailto:hancock.robert@gmail.com">hancock.robert@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have a process that takes a list of URLs, uses client.getPage() to<br>
retrieve the data, writes the contents to disk, and then moves the<br>
file to another directory.<br>
<br>
 &nbsp; # get feed list - this is a list tuples<br>
 &nbsp; &nbsp;# url, name, username, password<br>
 &nbsp; &nbsp;url_tuples = feed_list(feed_file)<br>
<br>
 &nbsp; &nbsp;global C_URLS<br>
 &nbsp; &nbsp;d = &nbsp;defer.succeed(log_start(log))<br>
<br>
 &nbsp; &nbsp;for tup_url in url_tuples:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;C_URLS += 1<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addCallback(get_page, tup_url)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addErrback(get_page_error, tup_url[0])<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addCallback(page_to_file, tup_url)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addErrback(page_to_file_error)<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addCallback(file_to_rsync_queue)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addErrback(file_to_rsync_queue)<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;d.addCallback(stop_working)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;#d.addErrback(self.gotError, (feed[0], &#39;while stopping&#39;))<br>
<br>
 &nbsp; &nbsp;reactor.run()<br>
<br>
I want to put this into a loop and run it as a daemon, but the looping<br>
is causing me a problem. &nbsp;I&#39;ve tried making the above into a procedure<br>
(minus the stop working call back and reactor.run()) &nbsp;and it does not<br>
run. &nbsp;Any suggestions on how to encapsulate this into loop would be<br>
gratefully appreciated.<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Blog: &nbsp;<a href="http://channel3b.wordpress.com">http://channel3b.wordpress.com</a><br>Second Life Name: &nbsp;Ciemaar Flintoff<br><br>How could you possibly think typing &#39;import skynet&#39; was a good idea?<br>
<a href="http://xkcd.com/521/">http://xkcd.com/521/</a><br>