Re: [Freeipa-devel] [PATCH 0039] Rate-limit while loop in SystemdService.is_active()

2015-06-29 Thread Martin Basti

On 26/06/15 15:58, Petr Spacek wrote:

Hello,

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.


ACK

--
Martin Basti

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


Re: [Freeipa-devel] [PATCH 0039] Rate-limit while loop in SystemdService.is_active()

2015-06-29 Thread Tomas Babej
On 06/29/2015 01:28 PM, Martin Basti wrote:
 On 26/06/15 15:58, Petr Spacek wrote:
 Hello,

 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.

 ACK
 

Pushed to master: ee84c6ae78b55fc097cd586129f2d94eef22ab0a

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code


[Freeipa-devel] [PATCH 0039] Rate-limit while loop in SystemdService.is_active()

2015-06-26 Thread Petr Spacek
Hello,

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.

-- 
Petr^2 Spacek
From ce78ce4ab8ba28c4ca7183ea1415ea5e30839f9f Mon Sep 17 00:00:00 2001
From: Petr Spacek pspa...@redhat.com
Date: Fri, 26 Jun 2015 15:55:12 +0200
Subject: [PATCH] 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.
---
 ipaplatform/base/services.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py
index 24d7a73dfa9b4260be90603e460da3afa1747735..11fa27357e831fe237ea60ce0098bb32f92665c7 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:
-- 
2.1.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code