ext/pci: handle 'qubes-close' event

Move cache cleanup to 'qubes-close' event handler, instead of doing it
specifically in tests.
This commit is contained in:
Marek Marczykowski-Górecki 2020-01-11 01:12:01 +01:00
parent a89d3f0cae
commit 74e956e1f1
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 6 additions and 1 deletions

View File

@ -313,6 +313,12 @@ class PCIDeviceExtension(qubes.ext.Extension):
else:
raise
@qubes.ext.handler('qubes-close', system=True)
def on_app_close(self, app, event):
# pylint: disable=unused-argument,no-self-use
_cache_get.cache_clear()
@functools.lru_cache(maxsize=None)
def _cache_get(vm, ident):
''' Caching wrapper around `PCIDevice(vm, ident)`. '''

View File

@ -410,7 +410,6 @@ class QubesTestCase(unittest.TestCase):
self.loop = asyncio.get_event_loop()
self.addCleanup(self.cleanup_loop)
self.addCleanup(self.cleanup_traceback)
self.addCleanup(qubes.ext.pci._cache_get.cache_clear)
def cleanup_traceback(self):
'''Remove local variables reference from tracebacks to allow garbage