connection: Do mediadev setup in a thread

Otherwise a lot of XMLDesc calls are done from the main thread
at connection startup time.
This commit is contained in:
Cole Robinson 2014-09-11 17:44:59 -04:00
parent a94cc98238
commit f0ab054109
1 changed files with 14 additions and 9 deletions

View File

@ -846,17 +846,22 @@ class vmmConnection(vmmGObject):
####################
def _nodedev_mediadev_added(self, ignore1, name):
if name in self._mediadevs:
return
def _add_thread():
if name in self._mediadevs:
return
vobj = self.get_nodedev(name)
mediadev = vmmMediaDevice.mediadev_from_nodedev(vobj)
if not mediadev:
return
vobj = self.get_nodedev(name)
mediadev = vmmMediaDevice.mediadev_from_nodedev(vobj)
if not mediadev:
return
self._mediadevs[name] = mediadev
logging.debug("mediadev=%s added", name)
self.emit("mediadev-added", mediadev)
def _add_idle():
self._mediadevs[name] = mediadev
logging.debug("mediadev=%s added", name)
self.emit("mediadev-added", mediadev)
self.idle_add(_add_idle)
threading.Thread(target=_add_thread, name="AddMediadev").start()
def _nodedev_mediadev_removed(self, ignore1, name):
if name not in self._mediadevs: