Issues with threads

Morten W. Petersen morten at thingamy.net
Sat Dec 15 09:55:43 EST 2001


Hi,

I'm trying to implement a check-website-availability-in-n-seconds
script, and figured it was a good oppurtunity to play with threading
in Python.

I've implemented two modules:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/warp-framework/warp_framework/tools/fork.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/warp-framework/warp_framework/tools/website_check.py?rev=1.4&content-type=text/vnd.viewcvs-markup

Where a test is run every time the website_check script is run.  The
test is rigged so that it will fail every time (and leave the thread
running), however, even though the thread is set to be daemonic, the
python interpreter doesn't always exit, it may hang after an arbitrary
number of calls:

morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished

Here Ctrl-C is needed to exit the interpreter.

morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished
morten at debian:~/programming/python/projects/warp_framework/tools$
python website_check.py
(0, None)
finished

Here Ctrl-C is again needed to exit the interpreter.

I've noticed that 1 or more expressions after the check_url_time
(seemingly) makes the interpreter exit more often that without
expressions after the call.

Any ideas what might be causing the interpreter to 'not exit
cleanly' ?

Thanks,

Morten



More information about the Python-list mailing list