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> def __init__(self,oaf,interval=600):<br> <br> self.interval=interval<br>
reactor.callLater(5,self.checkSystem)<br> <br> def checkSystem(self):<br> reactor.callLater(self.interval,self.checkSystem)<br><br>or like this:<br><br> def __init__(self,oaf,interval=600):<br>
<br>
self.interval=interval<br>
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"><<a href="mailto:hancock.robert@gmail.com">hancock.robert@gmail.com</a>></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>
# get feed list - this is a list tuples<br>
# url, name, username, password<br>
url_tuples = feed_list(feed_file)<br>
<br>
global C_URLS<br>
d = defer.succeed(log_start(log))<br>
<br>
for tup_url in url_tuples:<br>
C_URLS += 1<br>
<br>
d.addCallback(get_page, tup_url)<br>
d.addErrback(get_page_error, tup_url[0])<br>
<br>
d.addCallback(page_to_file, tup_url)<br>
d.addErrback(page_to_file_error)<br>
<br>
d.addCallback(file_to_rsync_queue)<br>
d.addErrback(file_to_rsync_queue)<br>
<br>
d.addCallback(stop_working)<br>
#d.addErrback(self.gotError, (feed[0], 'while stopping'))<br>
<br>
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. I've tried making the above into a procedure<br>
(minus the stop working call back and reactor.run()) and it does not<br>
run. 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: <a href="http://channel3b.wordpress.com">http://channel3b.wordpress.com</a><br>Second Life Name: Ciemaar Flintoff<br><br>How could you possibly think typing 'import skynet' was a good idea?<br>
<a href="http://xkcd.com/521/">http://xkcd.com/521/</a><br>