mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-11 10:56:39 +00:00
Use threading in ConnectionManager to test online status of hosts.
This commit is contained in:
parent
966b2fa459
commit
1e5af9bd87
@ -37,6 +37,7 @@ import gobject
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.xmlrpclib as xmlrpclib
|
import deluge.xmlrpclib as xmlrpclib
|
||||||
@ -80,6 +81,9 @@ class ConnectionManager(component.Component):
|
|||||||
|
|
||||||
self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, int)
|
self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, int)
|
||||||
|
|
||||||
|
# Holds the online status of hosts
|
||||||
|
self.online_status = {}
|
||||||
|
|
||||||
# Fill in hosts from config file
|
# Fill in hosts from config file
|
||||||
for host in self.config["hosts"]:
|
for host in self.config["hosts"]:
|
||||||
row = self.liststore.append()
|
row = self.liststore.append()
|
||||||
@ -174,7 +178,11 @@ class ConnectionManager(component.Component):
|
|||||||
def update_row(model=None, path=None, row=None, columns=None):
|
def update_row(model=None, path=None, row=None, columns=None):
|
||||||
uri = model.get_value(row, HOSTLIST_COL_URI)
|
uri = model.get_value(row, HOSTLIST_COL_URI)
|
||||||
uri = "http://" + uri
|
uri = "http://" + uri
|
||||||
online = self.test_online_status(uri)
|
threading.Thread(target=self.test_online_status, args=(uri,)).start()
|
||||||
|
try:
|
||||||
|
online = self.online_status[uri]
|
||||||
|
except:
|
||||||
|
online = False
|
||||||
|
|
||||||
if online:
|
if online:
|
||||||
image = gtk.STOCK_YES
|
image = gtk.STOCK_YES
|
||||||
@ -301,7 +309,7 @@ class ConnectionManager(component.Component):
|
|||||||
online = False
|
online = False
|
||||||
|
|
||||||
del host
|
del host
|
||||||
|
self.online_status[uri] = online
|
||||||
return online
|
return online
|
||||||
|
|
||||||
## Callbacks
|
## Callbacks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user