summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2013-06-18 08:46:24 -0400
committerCole Robinson <crobinso@redhat.com>2013-06-18 08:49:34 -0400
commit1c8bf88db78ff7eb4279edd760c6d6fdd14e3234 (patch)
treebddb08c5ff2e9c33b32e3a44348ef7cf5ed44696
parent660178abe13c8a78c678f179534493b7f3ce827a (diff)
downloadvirt-manager-1c8bf88db78ff7eb4279edd760c6d6fdd14e3234.tar.gz
baseclass: Add unregister wrappers for idle and timeout
If an idle handler raises an exception, it isn't unregistered and loops forever. This is a regression from previous pygobject and pygtk: https://bugzilla.gnome.org/show_bug.cgi?id=702552 Work around this for now with our own wrappers.
-rw-r--r--virtManager/baseclass.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/virtManager/baseclass.py b/virtManager/baseclass.py
index cc66e8a7..30fb39d9 100644
--- a/virtManager/baseclass.py
+++ b/virtManager/baseclass.py
@@ -18,9 +18,10 @@
# MA 02110-1301 USA.
#
+import logging
import os
import sys
-import logging
+import traceback
import virtManager
@@ -93,7 +94,6 @@ class vmmGObject(GObject.GObject):
self._gobject_timeouts.remove(handle)
def _logtrace(self, msg=""):
- import traceback
if msg:
msg += " "
logging.debug("%s(%s %s)\n:%s",
@@ -145,13 +145,25 @@ class vmmGObject(GObject.GObject):
"""
Make sure idle functions are run thread safe
"""
- return GLib.idle_add(func, *args)
+ def cb():
+ try:
+ return func(*args)
+ except:
+ print traceback.format_exc()
+ return False
+ return GLib.idle_add(cb)
def timeout_add(self, timeout, func, *args):
"""
Make sure timeout functions are run thread safe
"""
- ret = GLib.timeout_add(timeout, func, *args)
+ def cb():
+ try:
+ return func(*args)
+ except:
+ print traceback.format_exc()
+ return False
+ ret = GLib.timeout_add(timeout, cb)
self.add_gobject_timeout(ret)
return ret