mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 08:41:55 -06:00
schema cache: Read server info only once
Do not open/close the file with every access to plugins. Extensive access to filesystem may cause significant slowdown. https://fedorahosted.org/freeipa/ticket/6048 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
parent
83b46238e7
commit
6716aaedc8
@ -32,6 +32,9 @@ class ServerInfo(collections.MutableMapping):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, *_exc_info):
|
def __exit__(self, *_exc_info):
|
||||||
|
self.flush()
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
if self._dirty:
|
if self._dirty:
|
||||||
self._write()
|
self._write()
|
||||||
|
|
||||||
@ -78,15 +81,21 @@ def get_package(api):
|
|||||||
if api.env.in_tree:
|
if api.env.in_tree:
|
||||||
from ipaserver import plugins
|
from ipaserver import plugins
|
||||||
else:
|
else:
|
||||||
with ServerInfo(api) as server_info:
|
client = rpcclient(api)
|
||||||
client = rpcclient(api)
|
client.finalize()
|
||||||
client.finalize()
|
|
||||||
try:
|
try:
|
||||||
plugins = schema.get_package(api, server_info, client)
|
server_info = api._server_info
|
||||||
except schema.NotAvailable:
|
except AttributeError:
|
||||||
plugins = compat.get_package(api, server_info, client)
|
server_info = api._server_info = ServerInfo(api)
|
||||||
finally:
|
|
||||||
if client.isconnected():
|
try:
|
||||||
client.disconnect()
|
plugins = schema.get_package(api, server_info, client)
|
||||||
|
except schema.NotAvailable:
|
||||||
|
plugins = compat.get_package(api, server_info, client)
|
||||||
|
finally:
|
||||||
|
server_info.flush()
|
||||||
|
if client.isconnected():
|
||||||
|
client.disconnect()
|
||||||
|
|
||||||
return plugins
|
return plugins
|
||||||
|
Loading…
Reference in New Issue
Block a user