Skip to content

Commit

Permalink
Merge pull request #2270 from lfdversluis/issue-2183-fix-update-tracker
Browse files Browse the repository at this point in the history
Issue 2183 fix update tracker
  • Loading branch information
whirm committed Jun 9, 2016
2 parents 0309fa5 + ea55c77 commit 4b0b6c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion Tribler/Core/Modules/tracker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def get_tracker_info(self, tracker_url):
sanitized_tracker_url = get_uniformed_tracker_url(tracker_url)
return self._tracker_dict.get(sanitized_tracker_url)

@call_on_reactor_thread
def update_tracker_info(self, tracker_url, is_successful):
"""
Updates a tracker information.
Expand Down
14 changes: 8 additions & 6 deletions Tribler/Core/TorrentChecker/torrent_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from collections import deque
import logging
import time
from twisted.internet.error import ConnectingCancelledError

from twisted.internet.defer import Deferred, DeferredList, CancelledError

from twisted.internet import reactor
Expand Down Expand Up @@ -67,9 +69,6 @@ def shutdown(self):
"""
self._should_stop = True

# Stop the looping call
self.cancel_all_pending_tasks()

# it's now safe to block on the reactor thread
self.cancel_all_pending_tasks()

Expand Down Expand Up @@ -235,13 +234,16 @@ def on_error(failure):
"""
Handles the scenario of when a tracker session has failed by calling the
tracker_manager's update_tracker_info function.
:param _: ignored result of the Deferred.
:param failure: The failure object raised by Twisted.
"""
# Trap value errors that are thrown by e.g. the HTTPTrackerSession when a connection fails.
# And trap CancelledErrors that can be thrown when shutting down.
failure.trap(ValueError, CancelledError)
failure.trap(ValueError, CancelledError, ConnectingCancelledError)
self._logger.info(u"Failed to create session for tracker %s", tracker_session.tracker_url)
self._session.lm.tracker_manager.update_tracker_info(tracker_session.tracker_url, False)
# Do not update if the connection got cancelled, we are probably shutting down
# and the tracker_manager may have shutdown already.
if failure.check(CancelledError, ConnectingCancelledError) is None:
self._session.lm.tracker_manager.update_tracker_info(tracker_session.tracker_url, False)

# Make the connection to the trackers and handle the response
deferred = tracker_session.connect_to_tracker()
Expand Down

0 comments on commit 4b0b6c3

Please sign in to comment.