33 @param args arguments to pass to target |
33 @param args arguments to pass to target |
34 @param kwargs keyword arguments to pass to target |
34 @param kwargs keyword arguments to pass to target |
35 @return The identifier of the created thread |
35 @return The identifier of the created thread |
36 """ |
36 """ |
37 if DebugClientBase.DebugClientInstance is not None: |
37 if DebugClientBase.DebugClientInstance is not None: |
38 return DebugClientBase.DebugClientInstance.attachThread(target, args, kwargs) |
38 return DebugClientBase.DebugClientInstance.attachThread( |
|
39 target, args, kwargs) |
39 else: |
40 else: |
40 return _original_start_thread(target, args, kwargs) |
41 return _original_start_thread(target, args, kwargs) |
41 |
42 |
42 # make _thread hooks available to system |
43 # make _thread hooks available to system |
43 _original_start_thread = _thread.start_new_thread |
44 _original_start_thread = _thread.start_new_thread |
64 DebugClientBase.DebugClientBase.__init__(self) |
65 DebugClientBase.DebugClientBase.__init__(self) |
65 |
66 |
66 # protection lock for synchronization |
67 # protection lock for synchronization |
67 self.clientLock = RLock() |
68 self.clientLock = RLock() |
68 |
69 |
69 # the "current" thread, basically the thread we are at a breakpoint for. |
70 # the "current" thread, basically the thread we are at a breakpoint |
|
71 # for. |
70 self.currentThread = None |
72 self.currentThread = None |
71 |
73 |
72 # special objects representing the main scripts thread and frame |
74 # special objects representing the main scripts thread and frame |
73 self.mainThread = None |
75 self.mainThread = None |
74 self.mainFrame = None |
76 self.mainFrame = None |
75 |
77 |
76 self.variant = 'Threaded' |
78 self.variant = 'Threaded' |
77 |
79 |
78 def attachThread(self, target=None, args=None, kwargs=None, mainThread=False): |
80 def attachThread(self, target=None, args=None, kwargs=None, |
|
81 mainThread=False): |
79 """ |
82 """ |
80 Public method to setup a thread for DebugClient to debug. |
83 Public method to setup a thread for DebugClient to debug. |
81 |
84 |
82 If mainThread is non-zero, then we are attaching to the already |
85 If mainThread is non-zero, then we are attaching to the already |
83 started mainthread of the app and the rest of the args are ignored. |
86 started mainthread of the app and the rest of the args are ignored. |
84 |
87 |
85 @param target the start function of the target thread (i.e. the user code) |
88 @param target the start function of the target thread (i.e. the |
|
89 user code) |
86 @param args arguments to pass to target |
90 @param args arguments to pass to target |
87 @param kwargs keyword arguments to pass to target |
91 @param kwargs keyword arguments to pass to target |
88 @param mainThread True, if we are attaching to the already |
92 @param mainThread True, if we are attaching to the already |
89 started mainthread of the app |
93 started mainthread of the app |
90 @return identifier of the created thread |
94 @return identifier of the created thread |