mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
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.
This commit is contained in:
parent
660178abe1
commit
1c8bf88db7
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user