472,988 Members | 3,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 software developers and data experts.

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 2924
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Thomas Lindgaard | last post by:
Hello I have a multi-threaded web spider and it has a problem (probably several). Is there a way to make the debugger show me what my worker threads are doing? I can only get it to follow the...
2
by: pradyumna | last post by:
In Project settins - C/C++ - Code Generation, what is the difference between the option "Multithreaded" and "Multithreaded DLL". I understand that on selecting multithreaded option, single and...
3
by: Development | last post by:
I am creating 10 threads that do ecatly the same thing. I am having a very hard time debugging this scenario. It seems that by default when you are doing f10 or f11 all threads execute. You can...
4
by: Bruno van Dooren | last post by:
Hi, i was debugging a multithreaded app, when i stumbled across some weird behavior of the debugger. in the destructor of my main object i send a stop event to the worker thread, and then...
3
by: groups | last post by:
Hi all, I've recently ported a rather large C application to run multithreaded. A few functions have seriously deteriorated in performance, in particular when accessing a rather large global...
3
by: | last post by:
Is it possible to have just a multithreaded sub procedure? What I need is a timer time_elapsed event (2 sec interval) send params to a sub that is multithreaded. I have a COM component used to...
3
by: Jake K | last post by:
I have a multithreaded application that I now want to convert into a Windows Service. Does application.run work in a windows service? Are there things to take into consideration when creating a...
5
by: John Henry | last post by:
I am back against the wall trying to migrate my multithreaded application from Python 2.3 to 2.5. The part of the code that's failing has to do with queues (2.3 queues and 2.5 queues are not the...
33
by: fmassei | last post by:
Hello! I made a short piece of code that I find very useful for debugging, and I wanted to ask you if it is correct, somehow acceptable or if I simply reinvented the wheel. To deal with some bad...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.