You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2006/09/22 21:55:08 UTC
Python debugging tips
Mistakes in python client code often causes a fatal exception in one of
the worker threads leaving the main thread hanging. You see the worker
thread stack trace but have no idea where your code is at.
Anyone got debugging tips?
I'll fix it if I can but I have to learn the python client better first
so it might take a while.
Cheers,
Alan.
Re: Python debugging tips
Posted by Rafael Schloming <ra...@redhat.com>.
Alan Conway wrote:
> Mistakes in python client code often causes a fatal exception in one of
> the worker threads leaving the main thread hanging. You see the worker
> thread stack trace but have no idea where your code is at.
>
> Anyone got debugging tips?
For general python debugging check out the python debugger module:
http://docs.python.org/lib/module-pdb.html
For more specialized stuff you can use sys.settrace to do just about
anything. It's documented in the "How it Works" section of the above
module docs.
In this particular case you might just try putting a few prints in
Queue.get since that's the likely spot the thread is hanging.
--Rafael
Re: Python debugging tips
Posted by Alan Conway <ac...@redhat.com>.
On Fri, 2006-09-22 at 23:19 -0400, Rafael Schloming wrote:
> Glancing at the code it appears that the queues created in client.py to
> hold incoming messages never get closed. If the main thread were waiting
> on one of these when a fatal error occurred in another thread then the
> main thread would never be notified of the error and just hang. Does
> this sound like it could be the cause of your problem?
It does alright. In a hang situation like this I can't find any way to
get python to give me a stack trace from threads other than the one that
blows up. I'll try the debugging tips you gave in your other mail to
narrow it down.
Thanks,
Alan.
Re: Python debugging tips
Posted by Rafael Schloming <ra...@redhat.com>.
Hmm, that's not supposed to happen. I tried to make sure that all
exceptions (intentional or otherwise) eventually propagate back to the
main thread. In particular the Queue.close method is supposed to be
called for all queues in order to ensure that any thread waiting on the
queue will error out.
Glancing at the code it appears that the queues created in client.py to
hold incoming messages never get closed. If the main thread were waiting
on one of these when a fatal error occurred in another thread then the
main thread would never be notified of the error and just hang. Does
this sound like it could be the cause of your problem?
--Rafael
Alan Conway wrote:
> Mistakes in python client code often causes a fatal exception in one of
> the worker threads leaving the main thread hanging. You see the worker
> thread stack trace but have no idea where your code is at.
>
> Anyone got debugging tips?
>
> I'll fix it if I can but I have to learn the python client better first
> so it might take a while.
>
> Cheers,
> Alan.
>