我想知道我的Process是否已停止使用启动此Process的函数
from multiprocessing import Process
def parent_function():
i = 0
while True:
#some code processing
if i == 0: #start this process only first time
temp = Process(target=process_function)
temp.start()
def process_function():
While True:
#some code waiting or processing
如果process_function()
parent_function
发生了某些异常,我的parent_function()
就不知道。如何从process_function()
再次重新启动该流程功能,并继续检查 Sub aa()
Set Excel1 = ThisWorkbook.Sheets("Sheet1")
Set Excel2 = ThisWorkbook.Sheets("Sheet2")
Dim Excel1LR: Excel1LR = Excel1.Range("A1").CurrentRegion.Rows.Count
Dim Excel2LR: Excel2LR = Excel2.Range("A1").CurrentRegion.Rows.Count
For i = 2 To Excel1LR
Dim Value1: Value1 = Excel1.Range("A" & i).Value
For j = 2 To Excel2LR
Dim Value2: Value2 = Excel2.Range("A" & j).Value
If Value1 = Value2 Then
Dim Value3: Value3 = Excel2.Range("B" & j).Value
If Value3 = 1 Then
Excel1.Range("B" & i).Value = "topper"
ElseIf Value3 >= 2 And Value3 <= 4 Then
Excel1.Range("B" & i).Value = "average"
Else
Excel1.Range("B" & i).Value = "weak"
End If
Else
End If
Next
Next
msgbox "done"
End Sub
是否正在运行。
答案 0 :(得分:1)
您可以使用is_alive()
方法检查子进程是否已终止。它会返回True
或False
。在parent_function()
:
if not temp.is_alive():
# restart the process