| 17 | |
| 18 | |
| 19 | class wvmEventLoop(threading.Thread): |
| 20 | def __init__(self, group=None, target=None, name=None, args=(), kwargs={}): |
| 21 | # register the default event implementation |
| 22 | # of libvirt, as we do not have an existing |
| 23 | # event loop. |
| 24 | libvirt.virEventRegisterDefaultImpl() |
| 25 | |
| 26 | if name is None: |
| 27 | name = 'libvirt event loop' |
| 28 | |
| 29 | super(wvmEventLoop, self).__init__(group, target, name, args, kwargs) |
| 30 | |
| 31 | # we run this thread in deamon mode, so it does |
| 32 | # not block shutdown of the server |
| 33 | self.daemon = True |
| 34 | |
| 35 | def run(self): |
| 36 | while True: |
| 37 | # if this method will fail it raises libvirtError |
| 38 | # we do not catch the exception here so it will show up |
| 39 | # in the logs. Not sure when this call will ever fail |
| 40 | libvirt.virEventRunDefaultImpl() |
| 41 | |
| 42 | |
| 43 | class wvmConnection(object): |