http web fetch question

Tim Roberts timr at probo.com
Sat Apr 25 02:42:56 EDT 2009


grocery_stocker <cdalten at gmail.com> wrote:

>On Apr 23, 3:29 pm, Chris Rebert <c... at rebertia.com> wrote:
>> On Thu, Apr 23, 2009 at 3:21 PM, grocery_stocker <cdal... at gmail.com> wrote:
>> > Say I have a script that fetches data from a website every hour. Is
>> > there a general solution or is the solution operating system specific?
>>
>> WRT the periodic operation part of your task, there's the `sched`
>> module --http://docs.python.org/library/sched.html
>
>Maybe I'm being a tad bit dense here, but I don't see how this
>schedule mod can be used to fetch data from a website every hour for
>10 hours straight...

Really?
    s = sched.scheduler( time.time, time.sleep )
    for hour in range(10):
        s.enter( 3600 * hour, 1, fetch_website, () )
    s.run()

>and why this is different than using something like time.sleep().

It's not different.  sched.scheduler uses time.sleep.  It just does so in
an abstracted way.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list