#2205: Exception after removing torrent
--------------------------+-------------------------------------------------
 Reporter:  gazpachoking  |       Owner:       
     Type:  bug           |      Status:  new  
 Priority:  minor         |   Milestone:  1.3.6
Component:  gtkui         |     Version:  1.3.5
 Keywords:                |  
--------------------------+-------------------------------------------------

Comment(by Cas):

 It seems like a race condition between one (or same?) ui deleting and
 another's regular call to get_torrents_status still containing the deleted
 torrent id.

 This should prevent the error:

 {{{
 #!diff

 diff --git a/deluge/ui/sessionproxy.py b/deluge/ui/sessionproxy.py
 index 88a77e9..660cd31 100644
 --- a/deluge/ui/sessionproxy.py
 +++ b/deluge/ui/sessionproxy.py
 @@ -102,10 +102,11 @@ def create_status_dict(self, torrent_ids, keys):
          """
          sd = {}
          for torrent_id in torrent_ids:
 -            if keys:
 -                sd[torrent_id] = dict([(x, y) for x, y in
 self.torrents[torrent_id][1].iteritems() if x in keys])
 -            else:
 -                sd[torrent_id] = dict(self.torrents[torrent_id][1])
 +            if torrent_id in self.torrents:
 +                if keys:
 +                    sd[torrent_id] = dict([(x, y) for x, y in
 self.torrents[torrent_id][1].iteritems() if x in keys])
 +                else:
 +                    sd[torrent_id] = dict(self.torrents[torrent_id][1])

          return sd

 @@ -194,15 +195,16 @@ def find_torrents_to_fetch(torrent_ids):
              to_fetch = []
              t = time.time()
              for torrent_id in torrent_ids:
 -                torrent = self.torrents[torrent_id]
 -                if t - torrent[0] > self.cache_time:
 -                    to_fetch.append(torrent_id)
 -                else:
 -                    # We need to check if a key is expired
 -                    for key in keys:
 -                        if t - self.cache_times[torrent_id].get(key, 0.0)
 > self.cache_time:
 -                            to_fetch.append(torrent_id)
 -                            break
 +                if torrent_id in self.torrents:
 +                    torrent = self.torrents[torrent_id]
 +                    if t - torrent[0] > self.cache_time:
 +                        to_fetch.append(torrent_id)
 +                    else:
 +                        # We need to check if a key is expired
 +                        for key in keys:
 +                            if t - self.cache_times[torrent_id].get(key,
 0.0) > self.cache_time:
 +                                to_fetch.append(torrent_id)
 +                                break

              return to_fetch
 #-----------------------------------------------------------------------

 }}}

-- 
Ticket URL: <http://dev.deluge-torrent.org/ticket/2205#comment:3>
Deluge <http://deluge-torrent.org/>
Deluge project

-- 
You received this message because you are subscribed to the Google Groups 
"Deluge Dev" group.
To post to this group, send email to deluge-dev@googlegroups.com.
To unsubscribe from this group, send email to 
deluge-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/deluge-dev?hl=en.

Reply via email to