47 # Note: import threading here AFTER above hook, as threading cache's |
46 # Note: import threading here AFTER above hook, as threading cache's |
48 # thread._start_new_thread. |
47 # thread._start_new_thread. |
49 from threading import RLock |
48 from threading import RLock |
50 |
49 |
51 |
50 |
52 class DebugClientThreads(DebugClientBase.DebugClientBase, AsyncIO): |
51 class DebugClientThreads(DebugClientBase.DebugClientBase): |
53 """ |
52 """ |
54 Class implementing the client side of the debugger. |
53 Class implementing the client side of the debugger. |
55 |
54 |
56 This variant of the debugger implements a threaded debugger client |
55 This variant of the debugger implements a threaded debugger client |
57 by subclassing all relevant base classes. |
56 by subclassing all relevant base classes. |
58 """ |
57 """ |
59 def __init__(self): |
58 def __init__(self): |
60 """ |
59 """ |
61 Constructor |
60 Constructor |
62 """ |
61 """ |
63 AsyncIO.__init__(self) |
|
64 |
|
65 DebugClientBase.DebugClientBase.__init__(self) |
62 DebugClientBase.DebugClientBase.__init__(self) |
66 |
63 |
67 # protection lock for synchronization |
64 # protection lock for synchronization |
68 self.clientLock = RLock() |
65 self.clientLock = RLock() |
69 |
66 |
80 def attachThread(self, target=None, args=None, kwargs=None, |
77 def attachThread(self, target=None, args=None, kwargs=None, |
81 mainThread=False): |
78 mainThread=False): |
82 """ |
79 """ |
83 Public method to setup a thread for DebugClient to debug. |
80 Public method to setup a thread for DebugClient to debug. |
84 |
81 |
85 If mainThread is non-zero, then we are attaching to the already |
82 If mainThread is True, then we are attaching to the already |
86 started mainthread of the app and the rest of the args are ignored. |
83 started mainthread of the app and the rest of the args are ignored. |
87 |
84 |
88 @param target the start function of the target thread (i.e. the |
85 @param target the start function of the target thread (i.e. the |
89 user code) |
86 user code) |
90 @param args arguments to pass to target |
87 @param args arguments to pass to target |
129 def lockClient(self, blocking=True): |
126 def lockClient(self, blocking=True): |
130 """ |
127 """ |
131 Public method to acquire the lock for this client. |
128 Public method to acquire the lock for this client. |
132 |
129 |
133 @param blocking flag to indicating a blocking lock |
130 @param blocking flag to indicating a blocking lock |
|
131 @type bool |
134 @return flag indicating successful locking |
132 @return flag indicating successful locking |
|
133 @rtype bool |
135 """ |
134 """ |
136 if blocking: |
135 if blocking: |
137 self.clientLock.acquire() |
136 self.clientLock.acquire() |
138 else: |
137 else: |
139 return self.clientLock.acquire(blocking) |
138 return self.clientLock.acquire(blocking) |