Network statistics program

Cedric Adjih adjih at crepuscule.com
Wed May 17 06:05:40 EDT 2000


Greg Fortune <gfor_ewu at ispchannel.com> wrote:
>     I'm currently working on a program that will run some network statistics
> for me over the span of months.  I want to send a ping every minute, collect
> the results, and then store that information in a database.  I think I can
> get everything working, but the issue of the one minute interval is killing
> me.  How do I make my program just sit there and do nothing until the system
> clock says it has been a minute?  Never before have I *tried* to make a
> program do nothing  :).
>     I consider a while loop with a pass statement or a time check, but that
> seems like it would take up processor cycles for little reason.
>     I also considered letting ping handle the interval and just use ping as
> the piped input. Although this may be the simplest solution for me at this
> time, I really want to learn how to implement delay.

You can use module time, function sleep: 
  time.sleep(1.1) # sleep 1.1 seconds
Or if you are waiting for events or for a timeout, select
will be helpful:
  select.select([file desc list]..., timeOutInSeconds)
For instance if you are waiting for a ping reply.

-- Cedric




More information about the Python-list mailing list