diff options
author | Petr Spacek <pspacek@redhat.com> | 2015-06-26 15:55:12 +0200 |
---|---|---|
committer | Tomas Babej <tbabej@redhat.com> | 2015-06-29 13:39:07 +0200 |
commit | ee84c6ae78b55fc097cd586129f2d94eef22ab0a (patch) | |
tree | edda7343569d22b2c7531a324a655c46ac33ca08 /ipaplatform | |
parent | 29c01e5ef4d4bb8c608720c3e027d8d75b24fcd3 (diff) | |
download | freeipa-ee84c6ae78b55fc097cd586129f2d94eef22ab0a.tar.gz freeipa-ee84c6ae78b55fc097cd586129f2d94eef22ab0a.tar.xz freeipa-ee84c6ae78b55fc097cd586129f2d94eef22ab0a.zip |
Rate-limit while loop in SystemdService.is_active().
Previously is_active() was frenetically calling systemctl is_active in
tight loop which in fact made the process slower.
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipaplatform')
-rw-r--r-- | ipaplatform/base/services.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py index 24d7a73df..11fa27357 100644 --- a/ipaplatform/base/services.py +++ b/ipaplatform/base/services.py @@ -25,6 +25,7 @@ interacting with system services. import os import json +import time import ipalib from ipapython import ipautil @@ -53,6 +54,8 @@ wellknownports = { 'pki-tomcatd': [8080, 8443], # used if the incoming instance name is blank } +SERVICE_POLL_INTERVAL = 0.1 # seconds + class KnownServices(MagicDict): """ @@ -303,11 +306,13 @@ class SystemdService(PlatformService): ) except ipautil.CalledProcessError as e: if e.returncode == 3 and 'activating' in str(e.output): + time.sleep(SERVICE_POLL_INTERVAL) continue return False else: # activating if rcode == 3 and 'activating' in str(sout): + time.sleep(SERVICE_POLL_INTERVAL) continue # active if rcode == 0: |