I want to do something:

Soup-a-Stu stupot999 at hotmail.com
Sun Jul 29 22:53:22 EDT 2001


i get given a new IP every single connection, vecause i have free internet i
get disconnected every single 2 hours so in my case some hours would be bad,
every 10-15 minutes would be alright... possibly every 5.



"chris liechti" <cliechti at mails.ch> wrote in message
news:Xns90ECAC6078D75cliechtimailsch at 62.2.32.50...
> [posted and mailed]
>
> "Jeremy Moles" <xione at bellsouth.net> wrote in
> news:jYy87.177$vM1.2880 at e3500-atl1.usenetserver.com:
> > Basically, what this code does is get my IP address and upload it to my
> > webserver - since my IP is dynamic, and I never quite know what it is
> > when I leave this house.
> >
> > But anyways - how can I do this - say - every minute or so? Could I:
> >
> > import time
> >
> > while(time.time()%60==0):
> >     do_my_function()
> >
> this will not do what you want.. surround the modulo expression with
> int(...) otherwise it chances are small that it will be zero (the
> probability for the milliseconds beeing exacly zero are 1/1000 and % with
> floats returns a float reminder). also this while loop would exit when it
> sould do the function call but call it in a loop when you want to wait
(and
> does this with 100% CPU load)...
>
> i would do it with sleep:
> -------
> import time
>
> while 1:
>     do_my_function()     #upload file
>     time.sleep(600)    #wait ten minits
> -------
> i also think that ten minits or some hours are enough. usually the IP is
> valid for some longer time. i now get the same IP assigned (DHCP) for over
> one month and i switch off the pc every night.
>
> chris <cliechti at mails.ch>
>





More information about the Python-list mailing list