Python 而循环在满足所有条件之前退出

Python 而循环在满足所有条件之前退出,python,jython,oracle12c,wlst,Python,Jython,Oracle12c,Wlst,我用python编写了一个脚本来启动服务器。 在一个循环中,我检查它们的状态,以确保所有服务器都已启动,然后再继续 但不知何故,在所有条件都满足之前,循环就退出了 你知道为什么会这样吗 #check if all servers are RUNNING while (osb2State!='RUNNING') and (osb3State!='RUNNING') and (osb4State!='RUNNING') and (osb5State!='RUNNING') and (osb6Stat

我用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);

首先,这是Jython而不是python

第二,看看:

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

只有当所有状态均为==“正在运行”时,该条件才为真。因此,任何处于运行状态的服务器都会导致循环退出。如果您希望所有服务器在退出之前都已启动,请使用
而不是

@abadamso注意到您使用的java.lang.Thread与python不太相似。你确定你的标签是正确的吗?@ScottMermelstein:在我看来是正确的。虽然测试应该是正确的,只要所有服务器都在“运行”,所以每个测试之间应该有“或”,因为即使一个服务器没有运行,循环也应该循环,为了完美的实现,我将再添加一个变量-循环计数器,退出此循环并在所有服务器在一段时间内无法启动时调用exception,或者n循环运行以等待您的答复。我对Jython的理解是,它是带有java库的python,因此命名为Jython。但谢谢你强调我的错误。非常感谢!