mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Use try-except instead of if statement to gain a little performance
This commit is contained in:
parent
ac6785eb1a
commit
2a8b8e93da
1 changed files with 3 additions and 4 deletions
|
@ -571,12 +571,11 @@ class TorrentManager(component.Component):
|
||||||
:raises InvalidTorrentError: if the torrent_id is not in the session
|
:raises InvalidTorrentError: if the torrent_id is not in the session
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
if torrent_id not in self.torrents:
|
torrent_name = self.torrents[torrent_id].get_status(["name"])["name"]
|
||||||
|
except KeyError:
|
||||||
raise InvalidTorrentError("torrent_id not in session")
|
raise InvalidTorrentError("torrent_id not in session")
|
||||||
|
|
||||||
torrent_name = self.torrents[torrent_id].get_status(["name"])["name"]
|
|
||||||
|
|
||||||
# Emit the signal to the clients
|
# Emit the signal to the clients
|
||||||
component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))
|
component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue