summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Pinto <markybob@dipconsultants.com>2007-10-29 00:16:25 +0000
committerMarcos Pinto <markybob@dipconsultants.com>2007-10-29 00:16:25 +0000
commit54cd279b3420e63da4f9c7150461c90286730137 (patch)
treec54b6601c1f252bc4bb856f916689efe1d421bee
parentba7143acb9ff2d8a922af9c91a0cd4871996c658 (diff)
downloaddeluge-54cd279b3420e63da4f9c7150461c90286730137.tar.gz
deluge-54cd279b3420e63da4f9c7150461c90286730137.tar.bz2
deluge-54cd279b3420e63da4f9c7150461c90286730137.zip
thread to avoid race condition
-rw-r--r--src/interface.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/interface.py b/src/interface.py
index ed644c1ca..e0539f57b 100644
--- a/src/interface.py
+++ b/src/interface.py
@@ -943,23 +943,8 @@ window, please enter your password"))
self.load_tabs_order()
#now we load blocklist plugin separately since it takes much longer
enable_plugins = self.config.get('enabled_plugins').split(':')
- for torrent in self.manager.get_queue():
- unique_id = self.manager.get_torrent_unique_id(torrent)
- try:
- if self.manager.unique_IDs[unique_id].trackers:
- try:
- self.manager.replace_trackers(unique_id, \
- self.manager.unique_IDs[unique_id].trackers)
- except:
- pass
- if self.manager.unique_IDs[unique_id].uploaded_memory:
- try:
- self.manager.unique_IDs[unique_id].initial_uploaded_memory \
- = self.manager.unique_IDs[unique_id].uploaded_memory
- except:
- pass
- except AttributeError:
- pass
+
+ self.initial_reload_trackers(self.manager)
if "Blocklist Importer" in enable_plugins:
try:
@@ -975,6 +960,35 @@ window, please enter your password"))
except KeyboardInterrupt:
self.manager.quit()
+ def initial_reload_trackers(self, manager):
+ import threading
+ class ReloadTrackers(threading.Thread):
+ def __init__(self, manager):
+ threading.Thread.__init__(self)
+ self.manager = manager
+ def run(self):
+ import time
+ time.sleep(3)
+ for torrent in self.manager.get_queue():
+ unique_id = self.manager.get_torrent_unique_id(torrent)
+ try:
+ if self.manager.unique_IDs[unique_id].trackers:
+ try:
+ self.manager.replace_trackers(unique_id, \
+ self.manager.unique_IDs[unique_id].trackers)
+ except:
+ pass
+ if self.manager.unique_IDs[unique_id].uploaded_memory:
+ try:
+ self.manager.unique_IDs[unique_id].initial_uploaded_memory \
+ = self.manager.unique_IDs[unique_id].uploaded_memory
+ except:
+ pass
+ except AttributeError:
+ pass
+ ReloadTrackers(manager).start()
+
+
def load_plugins(self):
enable_plugins = self.config.get('enabled_plugins').split(':')
for plugin in enable_plugins: