Fix up config module to use twisted loop instead of gobject

This commit is contained in:
Andrew Resch 2009-02-04 02:47:02 +00:00
parent 523d494991
commit 3b6bee1508
1 changed files with 7 additions and 6 deletions

View File

@ -30,7 +30,7 @@ Deluge Config Module
import cPickle as pickle import cPickle as pickle
import shutil import shutil
import os import os
import gobject
import deluge.common import deluge.common
from deluge.log import LOG as log from deluge.log import LOG as log
@ -62,7 +62,7 @@ class Config(object):
self.__previous_config = {} self.__previous_config = {}
self.__set_functions = {} self.__set_functions = {}
self.__change_callback = None self.__change_callback = None
# This will get set with a gobject.timeout_add whenever a config option # This will get set with a reactor.callLater whenever a config option
# is set. # is set.
self.__save_timer = None self.__save_timer = None
@ -127,18 +127,19 @@ class Config(object):
self.__previous_config.update(self.__config) self.__previous_config.update(self.__config)
self.__config[key] = value self.__config[key] = value
# Run the set_function for this key if any # Run the set_function for this key if any
from twisted.internet import reactor
try: try:
gobject.idle_add(self.__set_functions[key], key, value) reactor.callLater(0, self.__set_functions[key], key, value)
except KeyError: except KeyError:
pass pass
try: try:
gobject.idle_add(self.__change_callback, key, value) reactor.callLater(0, self.__change_callback, key, value)
except: except:
pass pass
# We set the save_timer for 5 seconds if not already set # We set the save_timer for 5 seconds if not already set
if not self.__save_timer: if not self.__save_timer or not self.__save_timer.active():
self.__save_timer = gobject.timeout_add(5000, self.save) self.__save_timer = reactor.callLater(5, self.save)
def __getitem__(self, key): def __getitem__(self, key):
""" """