Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Debugging a Python Program that Hangs

Reply
Thread Tools

Debugging a Python Program that Hangs

 
 
Kevin D. Smith
Guest
Posts: n/a
 
      12-02-2008
I have a fairly large python program that, when a certain combination
of options is used, hangs. I have no idea where it is hanging, so
simply putting in print statements to locate the spot would be quite
difficult. Unfortunately, ctrl-C'ing the program doesn't print a
traceback either. Looking through the python debugger documentation, I
don't see how to run a python program and interactively stopping it
while it is running. Is there a way to stop within a running python
program to see where it is getting hung up?

--
Kevin D. Smith

 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      12-03-2008
On Dec 3, 2:19*am, Kevin D. Smith <Kevin.Sm...@sas.com> wrote:
> I have a fairly large python program that, when a certain combination
> of options is used, hangs. *I have no idea where it is hanging, so
> simply putting in print statements to locate the spot would be quite
> difficult. *Unfortunately, ctrl-C'ing the program doesn't print a
> traceback either. *Looking through the python debugger documentation, I
> don't see how to run a python program and interactively stopping it
> while it is running. *Is there a way to stop within a running python
> program to see where it is getting hung up?


Hey Kevin, long time fan of your films! (I bet you get that a lot...)

The trace module might help you identify where it's getting caught up:

http://www.python.org/doc/2.5.2/lib/trace-cli.html

 
Reply With Quote
 
 
 
 
Stef Mientki
Guest
Posts: n/a
 
      12-03-2008
check winpdb / rpdb2,
cheers,
Stef

On 12/3/08, alex23 <> wrote:
> On Dec 3, 2:19 am, Kevin D. Smith <Kevin.Sm...@sas.com> wrote:
>> I have a fairly large python program that, when a certain combination
>> of options is used, hangs. I have no idea where it is hanging, so
>> simply putting in print statements to locate the spot would be quite
>> difficult. Unfortunately, ctrl-C'ing the program doesn't print a
>> traceback either. Looking through the python debugger documentation, I
>> don't see how to run a python program and interactively stopping it
>> while it is running. Is there a way to stop within a running python
>> program to see where it is getting hung up?

>
> Hey Kevin, long time fan of your films! (I bet you get that a lot...)
>
> The trace module might help you identify where it's getting caught up:
>
> http://www.python.org/doc/2.5.2/lib/trace-cli.html
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
Kay Schluehr
Guest
Posts: n/a
 
      12-03-2008
On 2 Dez., 17:19, Kevin D. Smith <Kevin.Sm...@sas.com> wrote:
> I have a fairly large python program that, when a certain combination
> of options is used, hangs. *I have no idea where it is hanging, so
> simply putting in print statements to locate the spot would be quite
> difficult. *Unfortunately, ctrl-C'ing the program doesn't print a
> traceback either. *Looking through the python debugger documentation, I
> don't see how to run a python program and interactively stopping it
> while it is running. *Is there a way to stop within a running python
> program to see where it is getting hung up?
>
> --
> Kevin D. Smith


You might approximate the critical location using exceptions instead
of prints. That's more costly of course because the program has to be
restarted more often but it will serve the same purpose.
 
Reply With Quote
 
Ross Ridge
Guest
Posts: n/a
 
      12-03-2008
Kevin D. Smith <> wrote:
>I have a fairly large python program that, when a certain combination
>of options is used, hangs. I have no idea where it is hanging, so
>simply putting in print statements to locate the spot would be quite
>difficult. Unfortunately, ctrl-C'ing the program doesn't print a
>traceback either.


Have you tried catching the KeyboardInterrupt exception and printing
an exception? Something like:

try:
rest_of_program()
except KeyboardInterrupt:
traceback.print_exc()
raise

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo]
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
VS.NET hangs when starting with debugging John Dalberg ASP .Net 2 11-03-2005 08:14 PM
Gem hangs => TCPSocket.write hangs Tim Shadel Ruby 1 07-24-2005 06:11 AM
Clear hangs up - & hangs up - & hangs up Sue Bilstein NZ Computing 26 03-07-2004 01:33 AM
IDE hangs while debugging Michael ASP .Net 1 03-02-2004 12:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57