469,923 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

Debugging multithreaded scrips

I started with Python two weeks ago and already saved some time and
efforts while writing 2 programs:
1. database extraction and backup tool, which runs once a month and
creates a snapshot of important data, compresses and saves it.
2. pop3 "watchdog", which reads e-mail from a pop3 mailbox and in the
case there is no mail sends e-mail messages to technicians. (the
presence of e-mail in the mailbox tells that the system I'm monitoring
works fine).

Both programs run on W2K as services and I'm very satisfied with
Python.

I have two questions.

1. How one can debug multithreaded Python programs?

2. Is dynamic typing blessing or an opposite thing?

None of the debugging tools seems to be able to debug multithreaded
programs. I believe that all of them are based on pdb.py module.
pdb.py module also fails to stop on a breakpoint, which is in a
function, executed not in the main thread.

In multithreaded program you have to run some sort of a message loop
in the end of the main thread, waiting for some sort of termination
event (f.e. keyboard input or external signal). After receiving this
signal you terminate the thread(s) and exit the main thread.
raw_input("...") is also fine for signaling purposes (I use
kbhit/getch/sleep on Windows).

Pythonwin does not work with raw_input and threads - it creates system
modal dialog box and blocks its own windows updates (including the
interpreter window).

So I had to resort to UNIVERSAL print statement. Tell me about stone
age!

How are you debugging multithreaded Python programs???
Dynamic typing.

The problem: in languages like C++ or Java typos are caught by
compiler and have no way to break the run time. Not that good in
Python. Consider this:

a1=5
a2=6
def f(p1, p2): return p1 + p2
print f(a1, a2)

the program works fine for half a year, but then at 1:30 AM your boss
tells you that he wants this line printed 2 times. You change the
program:

a1=5
a2=6
def f(p1, p2): return p1 + p2
print f(a1, a2)
print f(a1, a3)

and go home. At 5:25 AM boss calls and tells you - you know what.

Such situations are impossible in compiled statically typed languages.

Is dynamic typing blessing or an opposite thing?
Jul 18 '05 #1
1 2712
Elbert Lev wrote:
1. How one can debug multithreaded Python programs?


Elbert,
Try rpdb debugger at:
http://rpdb.digitalpeers.com/
It is a debugger that supports multi threading.

Please tell me if it helped you.
Nir
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Thomas Lindgaard | last post: by
2 posts views Thread by pradyumna | last post: by
3 posts views Thread by Development | last post: by
4 posts views Thread by Bruno van Dooren | last post: by
5 posts views Thread by John Henry | last post: by
33 posts views Thread by fmassei | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.