Преглед на файлове

tests: fix already registered event impl

Frédéric Pierret (fepitre) преди 4 години
родител
ревизия
40156c3e78
променени са 1 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 6 3
      qubes/tests/__init__.py

+ 6 - 3
qubes/tests/__init__.py

@@ -99,9 +99,8 @@ except libvirt.libvirtError:
 
 if in_dom0:
     import libvirtaio
-    libvirt_event_impl = libvirtaio.virEventRegisterAsyncIOImpl()
-else:
-    libvirt_event_impl = None
+
+libvirt_event_impl = None
 
 try:
     in_git = subprocess.check_output(
@@ -395,6 +394,10 @@ class QubesTestCase(unittest.TestCase):
 
         self.loop = None
 
+        global libvirt_event_impl
+
+        if in_dom0 and not libvirt_event_impl:
+            libvirt_event_impl = libvirtaio.virEventRegisterAsyncIOImpl()
 
     def __str__(self):
         return '{}/{}/{}'.format(