|
|
403b09 |
From 6959578fdbdfd38113b26cd9e4f94b298343a6f0 Mon Sep 17 00:00:00 2001
|
|
|
403b09 |
From: David Kupka <dkupka@redhat.com>
|
|
|
403b09 |
Date: Tue, 9 Aug 2016 17:05:17 +0200
|
|
|
403b09 |
Subject: [PATCH] schema cache: Read server info only once
|
|
|
403b09 |
|
|
|
403b09 |
Do not open/close the file with every access to plugins. Extensive
|
|
|
403b09 |
access to filesystem may cause significant slowdown.
|
|
|
403b09 |
|
|
|
403b09 |
https://fedorahosted.org/freeipa/ticket/6048
|
|
|
403b09 |
|
|
|
403b09 |
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
|
|
|
403b09 |
---
|
|
|
403b09 |
ipaclient/remote_plugins/schema.py | 12 +++++++++++-
|
|
|
403b09 |
1 file changed, 11 insertions(+), 1 deletion(-)
|
|
|
403b09 |
|
|
|
403b09 |
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
|
|
|
403b09 |
index c72109ac3bb9b7a71f9cbc056eaf3a4d8371d035..aadc891750782b0961bc46989e3693d1d3ed0ecb 100644
|
|
|
403b09 |
--- a/ipaclient/remote_plugins/schema.py
|
|
|
403b09 |
+++ b/ipaclient/remote_plugins/schema.py
|
|
|
403b09 |
@@ -378,6 +378,9 @@ class ServerInfo(collections.MutableMapping):
|
|
|
403b09 |
return self
|
|
|
403b09 |
|
|
|
403b09 |
def __exit__(self, *_exc_info):
|
|
|
403b09 |
+ self.flush()
|
|
|
403b09 |
+
|
|
|
403b09 |
+ def flush(self):
|
|
|
403b09 |
if self._dirty:
|
|
|
403b09 |
self._write()
|
|
|
403b09 |
|
|
|
403b09 |
@@ -603,9 +606,16 @@ def get_package(api, client):
|
|
|
403b09 |
try:
|
|
|
403b09 |
schema = api._schema
|
|
|
403b09 |
except AttributeError:
|
|
|
403b09 |
- with ServerInfo(api.env.hostname) as server_info:
|
|
|
403b09 |
+ try:
|
|
|
403b09 |
+ server_info = api._server_info
|
|
|
403b09 |
+ except AttributeError:
|
|
|
403b09 |
+ server_info = api._server_info = ServerInfo(api)
|
|
|
403b09 |
+
|
|
|
403b09 |
+ try:
|
|
|
403b09 |
schema = Schema(api, server_info, client)
|
|
|
403b09 |
object.__setattr__(api, '_schema', schema)
|
|
|
403b09 |
+ finally:
|
|
|
403b09 |
+ server_info.flush()
|
|
|
403b09 |
|
|
|
403b09 |
fingerprint = str(schema['fingerprint'])
|
|
|
403b09 |
package_name = '{}${}'.format(__name__, fingerprint)
|
|
|
403b09 |
--
|
|
|
403b09 |
2.7.4
|
|
|
403b09 |
|