From a2a9f40b9a7ea6c9a4e7165800efd763b46e6d02 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Sun, 27 May 2018 20:45:53 +0200 Subject: [PATCH 1/7] Catching ConnectionLost error in torrent checker --- Tribler/Core/TorrentChecker/torrent_checker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tribler/Core/TorrentChecker/torrent_checker.py b/Tribler/Core/TorrentChecker/torrent_checker.py index 534ad182624..32b04e06971 100644 --- a/Tribler/Core/TorrentChecker/torrent_checker.py +++ b/Tribler/Core/TorrentChecker/torrent_checker.py @@ -6,7 +6,7 @@ from twisted.internet import reactor from twisted.internet.defer import DeferredList, CancelledError, fail, succeed, maybeDeferred -from twisted.internet.error import ConnectingCancelledError +from twisted.internet.error import ConnectingCancelledError, ConnectionLost from twisted.python.failure import Failure from twisted.web.client import HTTPConnectionPool @@ -254,7 +254,7 @@ def on_session_error(self, session, failure): And trap CancelledErrors that can be thrown when shutting down. :param failure: The failure object raised by Twisted. """ - failure.trap(ValueError, CancelledError, ConnectingCancelledError, RuntimeError) + failure.trap(ValueError, CancelledError, ConnectingCancelledError, ConnectionLost, RuntimeError) self._logger.warning(u"Got session error for URL %s: %s", session.tracker_url, failure) self.clean_session(session) From 3749a820b51771705342a6ee600fc009428f9de6 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Sun, 27 May 2018 20:46:41 +0200 Subject: [PATCH 2/7] Fixed left menu list timer --- TriblerGUI/widgets/leftmenuplaylist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TriblerGUI/widgets/leftmenuplaylist.py b/TriblerGUI/widgets/leftmenuplaylist.py index 03026bc49be..496354e0a88 100644 --- a/TriblerGUI/widgets/leftmenuplaylist.py +++ b/TriblerGUI/widgets/leftmenuplaylist.py @@ -40,7 +40,7 @@ def load_list(self, infohash): self.set_loading() if self.files_request_timer: - self.files_request_timer.invalidate() + self.files_request_timer.stop() self.files_request_timer = QTimer() self.files_request_timer.timeout.connect(self.perform_get_files_request) From 8c2efa1a6a600a930f8fa41cf177963d4c77535b Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Mon, 28 May 2018 14:43:18 +0200 Subject: [PATCH 3/7] Catching ConnectionLost when doing HTTP request --- Tribler/Core/Modules/restapi/torrentinfo_endpoint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tribler/Core/Modules/restapi/torrentinfo_endpoint.py b/Tribler/Core/Modules/restapi/torrentinfo_endpoint.py index 3fbece3b765..66e9236fa23 100644 --- a/Tribler/Core/Modules/restapi/torrentinfo_endpoint.py +++ b/Tribler/Core/Modules/restapi/torrentinfo_endpoint.py @@ -5,7 +5,7 @@ from libtorrent import bdecode, bencode from twisted.internet.defer import Deferred -from twisted.internet.error import DNSLookupError, ConnectError +from twisted.internet.error import DNSLookupError, ConnectError, ConnectionLost from twisted.web import http, resource from twisted.web.server import NOT_DONE_YET @@ -85,7 +85,7 @@ def on_metainfo_timeout(_): self.finish_request(request) def on_lookup_error(failure): - failure.trap(ConnectError, DNSLookupError, HttpError) + failure.trap(ConnectError, DNSLookupError, HttpError, ConnectionLost) request.setResponseCode(http.INTERNAL_SERVER_ERROR) request.write(json.dumps({"error": failure.getErrorMessage()})) self.finish_request(request) From 34bcdf54268583c0c41f55c24daf24e2affb7a51 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Mon, 28 May 2018 16:31:19 +0200 Subject: [PATCH 4/7] Fixed AlreadyCalled error in HTTP torrent checker --- Tribler/Core/TorrentChecker/session.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Tribler/Core/TorrentChecker/session.py b/Tribler/Core/TorrentChecker/session.py index 5d40d5eaa0a..fb561670e5d 100644 --- a/Tribler/Core/TorrentChecker/session.py +++ b/Tribler/Core/TorrentChecker/session.py @@ -199,6 +199,7 @@ def __init__(self, tracker_url, tracker_address, announce_page, timeout, connect self._content_length = None self._received_length = None self.result_deferred = None + self._parse_deferred = None self.request = None self._connection_pool = connection_pool if connection_pool else HTTPConnectionPool(reactor, False) @@ -266,7 +267,8 @@ def on_response(self, response): return # All ok, parse the body - self.register_task("parse_body", readBody(response).addCallbacks(self._process_scrape_response, self.on_error)) + self._parse_deferred = readBody(response).addCallbacks(self._process_scrape_response, self.on_error) + self.register_task("parse_body", self._parse_deferred) def _on_cancel(self, _): """ @@ -346,8 +348,14 @@ def cleanup(self): """ yield self._connection_pool.closeCachedConnections() yield super(HttpTrackerSession, self).cleanup() - self.request = None + # If we are in the process of reading a HTTP response from a remote server (with the readBody) method, it might + # be that it is called after the deferred has been cancelled already (by the super.cleanup method). This would + # result in an AlreadyCalled error. The following line prevents this behaviour. + if self._parse_deferred: + self._parse_deferred._suppressAlreadyCalled = True + + self.request = None self.result_deferred = None From a8057ea8bbb7208a6cd76644fd86a8aa28731aca Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Mon, 28 May 2018 21:47:04 +0200 Subject: [PATCH 5/7] Fixed bug when removing download and streaming it --- TriblerGUI/widgets/leftmenuplaylist.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TriblerGUI/widgets/leftmenuplaylist.py b/TriblerGUI/widgets/leftmenuplaylist.py index 496354e0a88..0dfd6fee289 100644 --- a/TriblerGUI/widgets/leftmenuplaylist.py +++ b/TriblerGUI/widgets/leftmenuplaylist.py @@ -48,14 +48,16 @@ def load_list(self, infohash): def perform_get_files_request(self): self.files_request_mgr = TriblerRequestManager() - self.files_request_mgr.perform_request("downloads/%s/files" % self.infohash, self.on_received_files) + self.files_request_mgr.perform_request("downloads/%s/files" % self.infohash, self.on_received_files, + capture_errors=False) def on_received_files(self, files): if "files" not in files or not files["files"]: return - self.files_request_timer.stop() - self.files_request_timer = None + if self.files_request_timer: + self.files_request_timer.stop() + self.files_request_timer = None self.set_files(files["files"]) self.loaded_list = True From 92be89448ad2c1b3dc00dfa167b72047d0250d6e Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Wed, 30 May 2018 12:03:03 +0200 Subject: [PATCH 6/7] Updated IPv8 pointer --- Tribler/pyipv8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tribler/pyipv8 b/Tribler/pyipv8 index 0201a852699..ac936563659 160000 --- a/Tribler/pyipv8 +++ b/Tribler/pyipv8 @@ -1 +1 @@ -Subproject commit 0201a85269939f79303a59df897d32f66de156c7 +Subproject commit ac936563659f4a53e28e0bb2b5a956a2cb44c318 From 190d028024949b18a3f269f0cc702cb0140e2af4 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Wed, 30 May 2018 12:09:36 +0200 Subject: [PATCH 7/7] Stopping token refresh timer on shutdown --- TriblerGUI/tribler_window.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TriblerGUI/tribler_window.py b/TriblerGUI/tribler_window.py index 24cf84175fb..f9584f0ccf1 100644 --- a/TriblerGUI/tribler_window.py +++ b/TriblerGUI/tribler_window.py @@ -825,6 +825,9 @@ def show_force_shutdown(): self.downloads_page.stop_loading_downloads() request_queue.clear() + # Stop the token balance timer + self.token_refresh_timer.stop() + def closeEvent(self, close_event): self.close_tribler() close_event.ignore()