def processEnded(self, processHandle, processHandleKey):
wfmoThread = self.phandleKeyToThreadHandle[processHandleKey]
processTransport = self.phandleToTransport[processHandle]
self.threadToNumEnded[wfmoThread] += 1
# Decrement proc handle count for thread
self.threadToNumProcessHandles[wfmoThread] -= 1
# If we go from 63 to 62 phandles for the thread, mark it available.
if self.threadToNumProcessHandles[wfmoThread] == 62:
self.availableThreads.append(wfmoThread)
self.usedThreads.remove(wfmoThread)
# If we go to 0 phandles, end the thread
elif self.threadToNumProcessHandles[wfmoThread] == 0:
# Mark thread as unavailable
self.availableThreads.remove(wfmoThread)
# Notify the thread that it should exit.
if not self.threadToMsgWindowCreated[wfmoThread]:
val = WaitForSingleObject(self.threadToMsgWindowCreationEvent[wfmoThread], INFINITE)
if val != WAIT_OBJECT_0:
raise RuntimeError("WaitForSingleObject returned %d. It should only return %d" % (val, WAIT_OBJECT_0))
# Notify the thread that it should wait on the process handle.
win32api.PostMessage(
self.threadToMsgWindow[wfmoThread], # thread id
WM_CLOSE_THREAD, # message
0, # wParam
0 # lParam
)
# Cleanup thread resources
del self.threadToNumProcessHandles[wfmoThread]
del self.threadToMsgWindowCreated[wfmoThread]
#del self.wfmoThread
# Cleanup process handle resources
del self.needWaiting[processHandleKey]
del self.phandleToTransport[processHandle]
# Call the transport's processEnded method
processTransport.processEnded()
评论列表
文章目录