threading

Parimala parimala.b at accord-soft.com
Wed Aug 13 09:06:51 CEST 2008


Hello,

       I am using *python2.5.1* version to run my test scripts. I want 
to use '*threading*' module in my tests. As a startup program, I had run 
the following one.

*import threading
import sys
import time

def hello():
  i=0
  try:
    while i<10:
      print "hi"
      time.sleep(1)
      i+=1
  except KeyboardInterrupt:
    print 'KeyboardInterrupt'
    raise KeyboardInterrupt

try:
  thread=threading.Thread(target=hello,args=())
  thread.start()
except KeyboardInterrupt:
  print 'KeyboardInterrupt'
  raise KeyboardInterrupt*

once program starts, problem is..
I am not able to abort the thread using (CTRL+C) *KeyboardInterrupt*.  
While running if I press CTRL+C, it won't generate any exception until 
the end of the execution. Once the execution gets over,  it will give 
"*Exception exceptions.KeyboardInterrupt in <module 'threading' from 
'C:\python25\lib\threading.py*'*> ignored*" this message and exits.

I had gone through some documents, it says if a thread is joined with 
*.join()* method then we can't stop that process until it releases the 
lock what it acquired. But in the above program I didn't use *.join()* 
method but still I am not able to abort the thread.

Could you please suggest me how can I abort the thread at any point in 
time using CTRL+C.

Thank you.

Regards,
Parimala.






##############################################################################################################################################
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination, copying or other use of, or taking any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited. If you have received this in error, please contact the sender and delete
the material from your system. Accord Software & Systems Pvt. Ltd. (ACCORD) is not responsible for any changes made to the material other
than those made by ACCORD or for the effect of the changes on the meaning of the material.
##############################################################################################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080813/5293a48d/attachment.html>


More information about the Python-list mailing list