Dear Tutors,

###################################
from threading import Thread
import sys
import time

# This thread would read lines from a
# barcode scanner
class ComThread(Thread):
    def __init__(self):
        Thread.__init__(self)
       
    def run(self):
        while 1:
            time.sleep(2)
            print time.ctime()

com = ComThread()
com.start()

# Main loop for handling the keyboard
while 1:
    s = raw_input()
    if s == '': continue
    elif s in 'qQ':
        # may I com.Terminate() here
        sys.exit()
        # when I goes out here
        # the comthread is just running.
    else:
        try:
            num = int(s)
            print 'mod qty=%d' % num
        except:
            pass
#################################

When this program leaves from the while loop, it doesn't terminate the comreader thread.
It can be terminated with the 'X' at the topright corner, but it seems to be not the best way.


Yours sincerely,
______________________________
Janos Juhasz

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to