From 2d49ef2f7cabb17e256a4ecfbac389a73924e2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 18 May 2020 04:28:01 +0200 Subject: [PATCH] events: implicitly enable caching when creating EventsDispatcher Application that runs EventsDispatcher can safely use also cache , which greatly improve performance. This is because cache then is properly updated/invalidated when needed. Instead of modifying each application to explicitly enable cache based on this simple rule, make it implicit when EventsDispatcher is created. QubesOS/qubes-issues#3293 --- qubesadmin/events/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qubesadmin/events/__init__.py b/qubesadmin/events/__init__.py index 48666853..4c9b5a59 100644 --- a/qubesadmin/events/__init__.py +++ b/qubesadmin/events/__init__.py @@ -32,9 +32,17 @@ class EventsDispatcher(object): ''' Events dispatcher, responsible for receiving events and calling appropriate handlers''' def __init__(self, app, api_method='admin.Events'): - '''Initialize EventsDispatcher''' + """Initialize EventsDispatcher + + Connecting :py:class:`EventsDispatcher` object to a + :py:class:`qubesadmin.Qubes` implicitly enables caching. It is important + to actually run the dispatcher (:py:meth:`listen_for_events`), otherwise + the cache won't be updated. Alternatively, disable caching by setting + :py:attr:`qubesadmin.Qubes.cache_enabled` property to `False`. + """ #: Qubes() object self.app = app + self.app.cache_enabled = True self._api_method = api_method