Fix add_torrent_url() to download the torrent file in a thread to

prevent the main thread from blocking and causing the daemon to freeze.
This commit is contained in:
Andrew Resch 2008-10-01 18:31:55 +00:00
commit 56b806ce78
3 changed files with 12 additions and 8 deletions

View file

@ -3,6 +3,8 @@ Deluge 1.0.1 (In Development)
* Change the default max global upload slots to 4 instead of -1 since libtorrent * Change the default max global upload slots to 4 instead of -1 since libtorrent
will automatically open more slots to meet the upload speed limit. will automatically open more slots to meet the upload speed limit.
* Fix display of tracker error messages * Fix display of tracker error messages
* Fix add_torrent_url() to download the torrent file in a thread to prevent
the main thread from blocking and causing the daemon to freeze.
GtkUI: GtkUI:
* Improve performance of files tab by only updating when values change * Improve performance of files tab by only updating when values change

View file

@ -396,9 +396,12 @@ class Core(
# Run the plugin hooks for 'post_torrent_add' # Run the plugin hooks for 'post_torrent_add'
self.plugins.run_post_torrent_add(torrent_id) self.plugins.run_post_torrent_add(torrent_id)
def export_add_torrent_url(self, url, save_path, options): def export_add_torrent_url(self, url, options):
log.info("Attempting to add url %s", url) log.info("Attempting to add url %s", url)
threading.Thread(target=self.fetch_torrent_url_thread, args=(self.export_add_torrent_file, url, options)).start()
def fetch_torrent_url_thread(self, callback, url, options):
# Get the actual filename of the torrent from the url provided. # Get the actual filename of the torrent from the url provided.
filename = url.split("/")[-1] filename = url.split("/")[-1]
@ -415,8 +418,7 @@ class Core(
return False return False
# Add the torrent to session # Add the torrent to session
return self.export_add_torrent_file( return callback(filename, filedump, options)
filename, filedump, options)
def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data): def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data):
log.debug("Removing torrent %s from the core.", torrent_ids) log.debug("Removing torrent %s from the core.", torrent_ids)

View file

@ -119,7 +119,7 @@ class torrent_add:
return return
if vars.url: if vars.url:
proxy.add_torrent_url(vars.url, None,options) proxy.add_torrent_url(vars.url, options)
log.debug("add-url:options :%s" % options) log.debug("add-url:options :%s" % options)
self.redirect(vars.choose_files) self.redirect(vars.choose_files)
elif torrent_name: elif torrent_name: