mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user