[Tutor] How to set a timer.

Kalle Svensson kalle@gnupung.net
Sat, 6 Jan 2001 23:48:49 +0100


--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Sez Budgester:
> What I want to do is read a web page on an internal server every 10 secon=
ds.
>=20
> So far I've can get the information I want from the web page working using
> 'urllib', but this is only a one time routine.
>=20
> The bit i am having problems with is calling the function at regular
> intervals.

The easiest way is probably a loop like this:

import time

while 1:
    time.sleep(10)
    #get page
    #do something with page contents
    if finished:
        break

If you are creating a GUI program with Tkinter, I think there is some more
elegant mechanism, but I don't know for sure.

HTH,
  Kalle
--=20
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD

--vtzGhvizbBRQ85DL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6V6DRdNeA1787sd0RAqiUAKCOx2w93qUABXhEoYl437lo58fc4QCgoRPG
X9GkR9WtwYFQD2ibgr3UbcA=
=9NRb
-----END PGP SIGNATURE-----

--vtzGhvizbBRQ85DL--