How to swallow traceback message

Tim Harig usernet at ilthio.net
Wed Aug 11 14:06:42 EDT 2010


On 2010-08-11, Back9 <backgoodoo at gmail.com> wrote:
> On Aug 11, 11:19 am, Tim Harig <user... at ilthio.net> wrote:
>> On 2010-08-11, Back9 <backgoo... at gmail.com> wrote:
>> > But when I try to exit it, normally I use Ctrl+ C key to quit it.
>> > Problem is every time I do like it, it shows Traceback message and it
>> > makes my app not professional.
>>
>> You have three options.
>>
>>         1. Exit more properly.
>>
>>         2. Catch and handle SIGINT yourself.
>>
>>         3. Wrap whatever section of your program is being interrupted in
>>                 try/except to catch the KeyboardInterrupt exception when it
>>                 is generated.
>
> I should have mentioned that I already use try/except
> KeyboardInterrupt statement.
> But it does not seem to work as I expected.

The either your code is somewhere outside of the try/except block when
it receives SIGINT, the exception is being caught somewhere below the
try/except clause that you added for KeyboardInterrupt,  or there is
something wrong with your handling code.  If you want much more help,
you are going to have to post some code to give us some specifics to
troubleshoot.



More information about the Python-list mailing list