Skip to content

Commit

Permalink
events: implicitly enable caching when creating EventsDispatcher
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmarek committed May 18, 2020
1 parent 5930e52 commit 2d49ef2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion qubesadmin/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2d49ef2

Please sign in to comment.