[Tutor] time.sleep problems
Glen Wheeler
wheelege@tsn.cc
Sat, 18 Nov 2000 19:41:39 +1100
This is a multi-part message in MIME format.
------=_NextPart_000_001B_01C05197.91FA85C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hey guys. I was just fiddling with threads and my code kept locking up. =
So I deicided to strip down the code. I did so, and it still locks up. =
I think the culprit is the time.sleep command. The code has been =
stripped to very simple (actually it as simple before too, but it kept =
erroring on me)
Anywho, here it is. I use a windows computer, and Python 2.0.
import thread
from time import sleep
print "Hi this is to show some thread stuff\n"
def thred(arg):
for i in range(10):
print arg
print i
sleep(0.0001)
t =3D raw_input('Hi! --> ')
if t =3D=3D 't' :
thread.start_new_thread(thred, (1,))
Thanks,
Glen.
------=_NextPart_000_001B_01C05197.91FA85C0
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 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Hey guys. I was just fiddling with threads and my code kept =
locking=20
up. So I deicided to strip down the code. I did so, and it =
still=20
locks up. I think the culprit is the time.sleep command. The =
code=20
has been stripped to very simple (actually it as simple before too, but =
it kept=20
erroring on me)</DIV>
<DIV> </DIV>
<DIV>Anywho, here it is. I use a windows computer, and Python =
2.0.</DIV>
<DIV> </DIV>
<DIV>import thread<BR>from time import sleep</DIV>
<DIV> </DIV>
<DIV>print "Hi this is to show some thread stuff\n"</DIV>
<DIV> </DIV>
<DIV>def thred(arg):<BR> for i in=20
range(10):<BR> print=20
arg<BR> print=20
i<BR> sleep(0.0001)</DIV>
<DIV><BR>t =3D raw_input('Hi! --> ')</DIV>
<DIV> </DIV>
<DIV>if t =3D=3D 't' :<BR> =
thread.start_new_thread(thred,=20
(1,))</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>Glen.</DIV></BODY></HTML>
------=_NextPart_000_001B_01C05197.91FA85C0--