Hi! I have a Pythonoob question.
I have a script that hangs indefinitely at random times; the only
thing to do at this point is to kill it.
I'm looking for suggestions on how to troubleshoot and debug the
problem.
I'm not even sure of where exactly the script is hanging, though
I suspect it is right around when it tries to read from a pipe
(generated by popen). (I arrived at this guess by putting print
statements all over the place, but I'm not sure this is a very
reliable way to pinpoint the error.)
So the first thing I'd like to do is find out exactly where the
script is hanging. It would be nice if I could just hit Ctrl-C
(which sends SIGINT from the terminal) when the script is hanging,
to kill it and get a backtrace, but when this script hangs it
becomes unresponsive to Ctrl-C! The only way to kill it is with
something like
% pkill -KILL my_script.py
or even
% pkill -TERM my_script.py
....or -ABRT or -QUIT. I tried to exploit this by adding this to the
script:
import signal
def term_handler(signum, frame):
raise KeyboardInterrupt
signal.signal(signal.SIGTERM, term_handler)
....but this did not help at all; in fact, after this addition, the script
no longer responded to pkill -TERM.
TIA!
Kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded. 2 8292
Hi,
Just a thought, I'm not sure it's the best way.
You can start an alarm just before the line you *think* it's wrong and
cancel it after that. If it's activated then you probably have
pinpointed the location. Have a look at the signals module http://docs.python.org/lib/module-signal.html, the alarm function.
Hope it helps.
kj wrote:
Hi! I have a Pythonoob question.
I have a script that hangs indefinitely at random times; the only
thing to do at this point is to kill it.
I'm looking for suggestions on how to troubleshoot and debug the
problem.
I'm not even sure of where exactly the script is hanging, though
I suspect it is right around when it tries to read from a pipe
(generated by popen). (I arrived at this guess by putting print
statements all over the place, but I'm not sure this is a very
reliable way to pinpoint the error.)
So the first thing I'd like to do is find out exactly where the
script is hanging. It would be nice if I could just hit Ctrl-C
(which sends SIGINT from the terminal) when the script is hanging,
to kill it and get a backtrace, but when this script hangs it
becomes unresponsive to Ctrl-C! The only way to kill it is with
something like
% pkill -KILL my_script.py
or even
% pkill -TERM my_script.py
...or -ABRT or -QUIT. I tried to exploit this by adding this to the
script:
import signal
def term_handler(signum, frame):
raise KeyboardInterrupt
signal.signal(signal.SIGTERM, term_handler)
...but this did not help at all; in fact, after this addition, the script
no longer responded to pkill -TERM.
TIA!
Kynn
kj a écrit :
Hi! I have a Pythonoob question.
I have a script that hangs indefinitely at random times; the only
thing to do at this point is to kill it.
I'm looking for suggestions on how to troubleshoot and debug the
problem.
I'm not even sure of where exactly the script is hanging, though
I suspect it is right around when it tries to read from a pipe
(generated by popen). (I arrived at this guess by putting print
statements all over the place, but I'm not sure this is a very
reliable way to pinpoint the error.)
So the first thing I'd like to do is find out exactly where the
script is hanging. It would be nice if I could just hit Ctrl-C
(which sends SIGINT from the terminal) when the script is hanging,
to kill it and get a backtrace, but when this script hangs it
becomes unresponsive to Ctrl-C!
Pretty often, this kind of behaviour is related to a catch-all (or at
least a 'catch-too-much') except clause that doesn't re-raise.
wrt/ debugging, there's a command-line debugger named pdb in the stdlib. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: frank |
last post by:
Hi all,
I have a largish asp-driven site that's crashing intermittently in a way
that's just causing me to scratch my head a lot. I've not seen this happen in
about five years of developing asp...
|
by: Pascal Damian |
last post by:
My HTML pages have a <SCRIPT SRC=http://remote/script> at the top'ish
of each page. Sometimes the remote host (probably due to heavy load or
flaky network connectivity) doesn't respond for a long...
|
by: Rochester |
last post by:
Hi,
I just found out that the general open file mechanism doesn't work
for named pipes (fifo). Say I wrote something like this and it
simply hangs python:
#!/usr/bin/python
import os
|
by: Azzuron |
last post by:
Hello everyone. We have a script with a periodic hanging query. What i mean, is that it sometimes seems to work, it sometimes seems to just hang up and never finish.
I have identified the query to...
|
by: jaimebienlesfruits |
last post by:
Hi,
I'm working on a website and I keep getting this error "SimpleswapSetup is not defined". I'm not really fluent in JS, so I haven't a clue what's going on.
Here's some code:
<!DOCTYPE html...
|
by: Adrian |
last post by:
Hi there
My VB Code looks something like that:
**************************************************************
Dim oShellApplication = CreateObject("Shell.Application")
Dim objWindow
For Each...
|
by: =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?= |
last post by:
Hello guys,
I was wondering if anybody here had implemented a solution where
Tables are aligned according to what the hanging indent tells us when
there is a potential for the table overflowing...
|
by: PJ6 |
last post by:
I can't figure this out. I have several references to style sheets and
javascript files in my page header, the contents of which are served
dynamically by my httphandler that serves *.res requests....
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |