<div>Any chance that there is a "catch-all" in the code.</div>
<div>As per PEP8 and I'm sure common knowledge of all the folks programming in Python for a while -- a</div>
<div>>>>catch:</div>
<div>could just lead to this problem.<br><br> </div>
<div><span class="gmail_quote">On 5/9/08, <b class="gmail_sendername">Floris Bruynooghe</b> <<a href="mailto:floris.bruynooghe@gmail.com">floris.bruynooghe@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On May 9, 11:19 am, <a href="mailto:spectru...@gmail.com">spectru...@gmail.com</a> wrote:<br>> Thanks for the replies.<br>
><br>> On May 8, 5:50 pm, Jean-Paul Calderone <<a href="mailto:exar...@divmod.com">exar...@divmod.com</a>> wrote:<br>><br>> > Ctrl+C often works with Python, but as with any language, it's possible<br>
> > to write a program which will not respond to it.  You can use Ctrl+\<br>> > instead (Ctrl+C sends SIGINT which can be masked or otherwise ignored,<br>> > Ctrl+\ sends SIGQUIT which typically isn't)<br>
><br>> Yes, thank you, this seems to work. :)<br>><br>> I did some more testing and found out that the problem seems to be<br>> thread-related. If I have a single-threaded program, then Ctrl+C<br>> usually works, but if I have threads, it is usually ignored. For<br>
> instance, the below program does not respond to Ctrl+C (but it does<br>> die when issued Ctrl+\):<br>><br>> import threading<br>><br>> def loop():<br>>   while True:<br>>     pass<br>><br>> threading.Thread(target=loop,args=()).start()<br>
<br>Your thread needs to be daemonised for this work.  Othewise your main<br>thread will be waiting for your created thread to finish.  E.g.:<br><br>thread = threading.Thread(target=loop)<br>thread.setDaemon(True)<br>thread.start()<br>
<br>But now it will exit immediately as soon as your main thread has<br>nothing to do anymore (which is right after .start() in this case), so<br>plug in another infinite loop at the end of this:<br><br>while True:<br>   time.sleep(10)<br>
<br>And now your threaded app will stop when using C-c.<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br><br clear="all">
<br>-- <br>regards,<br>Banibrata<br><a href="http://www.linkedin.com/in/bdutta">http://www.linkedin.com/in/bdutta</a><br><a href="http://octapod.wordpress.com">http://octapod.wordpress.com</a>