[Tutor] time.sleep problem

Joel Ricker joel@prettyhipprogramming.com
Mon, 8 Jul 2002 21:35:33 -0400


This is a multi-part message in MIME format.

------=_NextPart_000_0075_01C226C7.6404F8B0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Activestate Python 2.2.1, Windows 2000

I'm working on a script that uses time.sleep() but have found that on my =
installation, any sleep value over a few seconds seems to hang the =
script.  Not only does it not seem to respond anymore, it doesn't =
respond to ctrl+c.

Anybody else having this problem? Did I find a bug or could I just be =
doing something stupid?

My code, just in case:

    wait =3D None
   =20
    for o, a in opts:
        if o in ("-t", "--time"):
            wait =3D int(a) * 60
   =20
    while (1):
        addr =3D socket.gethostbyname(socket.getfqdn())
        print "The current address is", addr
        time.sleep(wait * 60)  =20

Tnx
Joel

------=_NextPart_000_0075_01C226C7.6404F8B0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2479.6" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Activestate Python 2.2.1, Windows =
2000</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm working on a script that uses =
time.sleep() but=20
have found that on my installation, any sleep value over a few seconds =
seems to=20
hang the script.&nbsp; Not only does it not seem to respond anymore, it =
doesn't=20
respond to ctrl+c.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anybody else having this =
problem?&nbsp;Did I find a=20
bug or could I just be doing something stupid?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My code, just in case:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;wait =3D=20
None<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; for o, a in=20
opts:<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if o in ("-t",=20
"--time"):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
wait =3D int(a) * 60<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; while=20
(1):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addr =3D=20
socket.gethostbyname(socket.getfqdn())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
print "The current address is",=20
addr<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(wait *=20
60)&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Tnx</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Joel</FONT></DIV></BODY></HTML>

------=_NextPart_000_0075_01C226C7.6404F8B0--