[Tutor] refresh-function

dman dman@dman.ddts.net
Mon, 27 May 2002 15:26:34 -0500


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

On Mon, May 27, 2002 at 12:34:34PM +0200, Thomas Jacobsen wrote:
| Hi,
|=20
| I have a program that needs a function that is running in a "while 1:" lo=
op,
| that runs with an interval, while other parts of the program is running.=
=20
| I was thinking of start the function in a thread, and use a  time.sleep
| method, so the whole program doesn't sleep, but i don't know if this is t=
he
| right/best way to do it.

That sounds like a good idea, as long as sleeping for a specific
amount of time is how "interval" is defined for your function.
Especially when using threads, you should be sure and understand the
Lock and Event classes from the threading module.  Depending on your
application, it may be better to use those instead of sleep().

HTH,
-D

--=20

How to shoot yourself in the foot with Java:

You find that Microsoft and Sun have released incompatible class
libraries both implementing Gun objects. You then find that although
there are plenty of feet objects implemented in the past in many other
languages, you cannot get access to one. But seeing as Java is so cool,
you don't care and go around shooting anything else you can find.
    (written by Mark Hammond)
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg


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

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

iEYEARECAAYFAjzylnoACgkQO8l8XBKTpRS+vwCaAnHNIycJXqeSI3a6xukgwaGG
mIYAoK03vtT+/VPunkzQEbfNnYPiRzdB
=DD3q
-----END PGP SIGNATURE-----

--KsGdsel6WgEHnImy--