Python threading.Timer функция не ждет 'n' секунд, прежде чем вызвать исключение - PullRequest
0 голосов
/ 04 февраля 2020

Я пытаюсь выяснить, почему таймер не ждет 300 секунд, а сразу вызывает исключение. Кто-нибудь может помочь мне решить эту проблему? спасибо.

вот мой код:

import sys
import os
from java.lang import System
import getopt
import time as systime
from threading import Timer
import time

[...]

def _startServer(ServerName):

    cd('domainRuntime:/ServerLifeCycleRuntimes/'+ServerName);
    state=_serverstatus(ServerName);

    while (state!='RUNNING'):

        try:
            cmo.start();
            while (state!='RUNNING'):
                state=_serverstatus(ServerName);
                java.lang.Thread.sleep(1000);

                t = threading.Timer(300.0,timeout)
                t.start()

        except:
            print 'Error in getting current status of ' +ServerName+ '\n';
            print 'Please check logged in user has full access to complete the start operation on ' +ServerName+ '\n';
            print 'Timeout, NodeManager may be down. Checking... ' + '\n';

            os.popen('sh /home/oracle/scripts/logAnalytics.sh')
            systime.sleep(60)

            state=_serverstatus(ServerName);

[...]

и результат:

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

172.31.129.68:7001
Connecting to t3://172.31.129.68:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'cll5_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.


Successfully connected to the domain

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)
Server Server_2 is :SHUTDOWN
Trying To Start Server:Server_2...
Server Server_2 is :SHUTDOWN
Server Server_2 is :SHUTDOWN
Error in getting current status of Server_2

Please check logged in user has full access to complete the start operation on Server_2

Timeout, NodeManager may be down. Checking...

Server Server_2 is :SHUTDOWN
Server Server_2 is :SHUTDOWN
Error in getting current status of Server_2

Please check logged in user has full access to complete the start operation on Server_2

Timeout, NodeManager may be down. Checking...

Server Server_2 is :RUNNING
Disconnected from weblogic server: AdminServer


Exiting WebLogic Scripting Tool.

(Обратите внимание, что строка «Server Server_2 is: SHUTDOWN» должна быть записана на экран несколько раз перед началом следующего процесса. Примерно 60 раз, потому что есть цикл while, который выводит строку состояния сервера каждые 5 секунд, а таймер составляет 300 секунд.)

Среда: Oracle Linux 6, Oracle Weblogi c 11

Любая помощь приветствуется.

...