Catch & log KeyError when removing a torrent from the queued torrents set

This seems to happen due to libtorrent firing the torrent finished event
twice.
This commit is contained in:
John Garland 2012-04-12 23:21:08 +10:00 committed by Calum Lind
parent 2cdcae8d31
commit acecd6d522
2 changed files with 13 additions and 2 deletions

View File

@ -41,6 +41,10 @@
would keep updating one call after the other. If the value changed, the
timer is now stopped and restarted using the new value.
=== Deluge 1.3.6 (In Development) ===
==== Core ====
* Catch & log KeyError when removing a torrent from the queued torrents set
=== Deluge 1.3.5 (09 April 2012) ===
==== GtkUI ====
* Modified fix for #1957, keyerror with non-acsii columns

View File

@ -633,7 +633,10 @@ class TorrentManager(component.Component):
# Remove from set if it wasn't finished
if not self.torrents[torrent_id].is_finished:
self.queued_torrents.remove(torrent_id)
try:
self.queued_torrents.remove(torrent_id)
except KeyError:
log.debug("%s isn't in queued torrents set?", torrent_id)
# Remove the torrent from deluge's session
try:
@ -951,7 +954,11 @@ class TorrentManager(component.Component):
torrent.update_state()
# Torrent is no longer part of the queue
self.queued_torrents.remove(torrent_id)
try:
self.queued_torrents.remove(torrent_id)
except KeyError:
# Sometimes libtorrent fires a TorrentFinishedEvent twice
log.debug("%s isn't in queued torrents set?", torrent_id)
# Only save resume data if it was actually downloaded something. Helps
# on startup with big queues with lots of seeding torrents. Libtorrent