在所有条件都为m之前退出循环

2024-10-01 19:19:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python编写了一个脚本来启动服务器。 在循环中,我检查它们的状态,以确保所有服务器都已启动,然后再继续。你知道吗

但不知何故,在所有条件都满足之前,循环就退出了。你知道吗

你知道为什么会这样吗?你知道吗

#check if all servers are RUNNING
while (osb2State!='RUNNING') and (osb3State!='RUNNING') and (osb4State!='RUNNING') and (osb5State!='RUNNING') and (osb6State!='RUNNING') :

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+sOSB2);
    osb2State = cmo.getState();
    if osb2State == 'ADMIN':
        resume(sOSB2);

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+sOSB3);
    osb3State = cmo.getState();
    if osb3State == 'ADMIN':
        resume(sOSB3);

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+sOSB4);
    osb4State = cmo.getState();
    if osb4State == 'ADMIN':
        resume(sOSB4);

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+sOSB5);
    osb5State = cmo.getState();
    if osb5State == 'ADMIN':
        resume(sOSB5);

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+sOSB6);
    osb6State = cmo.getState();
    if osb6State == 'ADMIN':
        resume(sOSB6);      

    java.lang.Thread.sleep(5000);

Tags: andifadmincdrunningresumegetstatecmo
1条回答
网友
1楼 · 发布于 2024-10-01 19:19:43

首先,这是Jython而不是python。你知道吗

第二,看看:

while (osb2State!='RUNNING') and (osb3State!='RUNNING') and (osb4State!='RUNNING') and (osb5State!='RUNNING') and (osb6State!='RUNNING') :

只有当的状态=='运行'时,条件才为真。因此,任何处于运行状态的服务器都会导致循环退出。如果您想在退出之前启动所有服务器,请使用or而不是and。你知道吗

相关问题 更多 >

    热门问题