SignalReceiver now initializes gobject threading.

This commit is contained in:
Andrew Resch 2007-10-24 09:52:20 +00:00
parent 0d3e319bea
commit 1144ee802f
3 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# #
# functions.py # client.py
# #
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #

View File

@ -47,7 +47,8 @@ class Signals(component.Component):
self.receiver.connect_to_signal("torrent_removed", self.receiver.connect_to_signal("torrent_removed",
self.torrent_removed_signal) self.torrent_removed_signal)
self.receiver.connect_to_signal("torrent_paused", self.torrent_paused) self.receiver.connect_to_signal("torrent_paused", self.torrent_paused)
self.receiver.connect_to_signal("torrent_resumed", self.torrent_resumed) self.receiver.connect_to_signal("torrent_resumed",
self.torrent_resumed)
self.receiver.connect_to_signal("torrent_all_paused", self.receiver.connect_to_signal("torrent_all_paused",
self.torrent_all_paused) self.torrent_all_paused)
self.receiver.connect_to_signal("torrent_all_resumed", self.receiver.connect_to_signal("torrent_all_resumed",

View File

@ -32,6 +32,9 @@
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
import sys import sys
import gobject
import deluge.ui.client as client import deluge.ui.client as client
import deluge.SimpleXMLRPCServer as SimpleXMLRPCServer import deluge.SimpleXMLRPCServer as SimpleXMLRPCServer
from SocketServer import ThreadingMixIn from SocketServer import ThreadingMixIn
@ -47,6 +50,7 @@ class SignalReceiver(
def __init__(self, port): def __init__(self, port):
log.debug("SignalReceiver init..") log.debug("SignalReceiver init..")
gobject.threads_init()
threading.Thread.__init__(self) threading.Thread.__init__(self)
# Set to true so that the receiver thread will exit # Set to true so that the receiver thread will exit
@ -105,14 +109,14 @@ class SignalReceiver(
if data != None: if data != None:
for callback in self.signals[signal]: for callback in self.signals[signal]:
try: try:
callback(data) gobject.idle_add(callback, data)
except: except:
log.warning("Unable to call callback for signal %s", log.warning("Unable to call callback for signal %s",
signal) signal)
else: else:
for callback in self.signals[signal]: for callback in self.signals[signal]:
try: try:
callback() gobject.idle_add(callback)
except: except:
log.warning("Unable to call callback for signal %s", log.warning("Unable to call callback for signal %s",
signal) signal)