Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Problem with multithreading

Reply
Thread Tools

Problem with multithreading

 
 
Jeffrey Barish
Guest
Posts: n/a
 
      06-24-2009
I have a program that uses multithreading to monitor two loops. When
something happens in loop1, it sends a message to loop2 to have it execute
a command. loop2 might have to return a result. If it does, it puts the
result in a queue. loop1, meanwhile, would have blocked waiting for
something to appear in the queue. The program works for a while, but
eventually freezes. I know that freezing is a sign of deadlock. However,
I put in print statements to localize the problem and discovered something
weird. The freeze always occurs at a point in the code with the following
statements:

print "about to try"
try:
print "in try"
<do something>

I get "about to try", but not "in try". Is this observation consistent with
the deadlock theory? If not, what could be making the program freeze at
the try statement? I wrote a test program using the same techniques to
illustrate the problem, but the test program works perfectly. I could post
it, though, if it would help to understand what I am doing -- and what
might be wrong in the real program.
--
Jeffrey Barish

 
Reply With Quote
 
 
 
 
Lie Ryan
Guest
Posts: n/a
 
      06-24-2009
Jeffrey Barish wrote:
> I have a program that uses multithreading to monitor two loops. When
> something happens in loop1, it sends a message to loop2 to have it execute
> a command. loop2 might have to return a result. If it does, it puts the
> result in a queue. loop1, meanwhile, would have blocked waiting for
> something to appear in the queue. The program works for a while, but
> eventually freezes. I know that freezing is a sign of deadlock. However,
> I put in print statements to localize the problem and discovered something
> weird. The freeze always occurs at a point in the code with the following
> statements:
>
> print "about to try"
> try:
> print "in try"
> <do something>
>
> I get "about to try", but not "in try". Is this observation consistent with
> the deadlock theory? If not, what could be making the program freeze at
> the try statement? I wrote a test program using the same techniques to
> illustrate the problem, but the test program works perfectly. I could post
> it, though, if it would help to understand what I am doing -- and what
> might be wrong in the real program.


The key in writing a test code is to reduce the buggy code until you
can't reduce anymore without losing the bug. It is sometimes difficult
to write a buggy test code...

try writing the test code again with that technique, and post it
 
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 with multithreading and Web services method invocation abhra.haldar@gmail.com ASP .Net 1 05-11-2006 04:21 PM
ASP.Net 2.0 Multithreading Problem insomniac ASP .Net 2 04-27-2006 05:03 PM
Python multithreading problem abhinav Python 3 03-27-2006 11:03 AM
Multithreading beginner problem Lee Garrington C++ 1 12-22-2003 02:12 PM
multithreading-problem Diez B. Roggisch Python 4 07-27-2003 08:35 PM



Advertisments