Problem with multithreading

Discussion in 'Python' started by Jeffrey Barish, Jun 24, 2009.

  1. 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
     
    Jeffrey Barish, Jun 24, 2009
    #1
    1. Advertising

  2. Jeffrey Barish

    Lie Ryan Guest

    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
     
    Lie Ryan, Jun 24, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. insomniac

    ASP.Net 2.0 Multithreading Problem

    insomniac, Apr 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,754
    insomniac
    Apr 27, 2006
  2. Lee Garrington

    Multithreading beginner problem

    Lee Garrington, Dec 22, 2003, in forum: C++
    Replies:
    1
    Views:
    567
    Thomas Matthews
    Dec 22, 2003
  3. Replies:
    1
    Views:
    3,173
    bruce barker \(sqlwork.com\)
    May 11, 2006
  4. Diez B. Roggisch

    multithreading-problem

    Diez B. Roggisch, Jul 27, 2003, in forum: Python
    Replies:
    4
    Views:
    350
    Diez B. Roggisch
    Jul 27, 2003
  5. abhinav

    Python multithreading problem

    abhinav, Mar 26, 2006, in forum: Python
    Replies:
    3
    Views:
    386
    abhinav
    Mar 27, 2006
Loading...

Share This Page