Debugging Multi-Threaded Python Programs
Jiba
a11w at SoftHome.net
Thu Aug 16 04:45:32 EDT 2001
Alan Green wrote:
>
> I've been trying to demonstrate Python debuggers to a colleague. One
> thing that everyone here is keen to see is debugging of multi-threaded
> programs.
>
> The program below is what I have been using to test - the idea is to
> catch a the 'naughty' thread modifying a shared global value. So far,
> I've only been able to set breakpoints on the program's main thread.
> Breakpoints on other threads do not work.
Just replace your global value by an attrib of a global object :
class MyClass: pass
SHARED_GLOBAL_OBJECT = MyClass()
SHARED_GLOBAL_OBJECT.value = 10
and use SHARED_GLOBAL_OBJECT.value instead of SHARED_GLOBAL_VALUE.
Then you can change the SHARED_GLOBAL_OBJECT class :
class MyClass:
def __setattr__(self, name, value):
print "value changed !"
self.__dict__[name] = value
You will be noticed for any change on SHARED_GLOBAL_OBJECT !
Jiba
More information about the Python-list
mailing list