Skip to content

Commit

Permalink
Remove ShutdownRequest class; add Request.cancellable attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Jan 30, 2023
1 parent dd61059 commit 908fd50
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/tribler/gui/core_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from typing import Optional

from PyQt5.QtCore import QObject, QProcess, QProcessEnvironment, QTimer
from PyQt5.QtNetwork import QNetworkRequest

from tribler.core.utilities.process_manager import ProcessManager
from tribler.gui import gui_sentry_reporter
from tribler.gui.app_manager import AppManager
from tribler.gui.event_request_manager import EventRequestManager
from tribler.gui.exceptions import CoreConnectTimeoutError, CoreCrashedError
from tribler.gui.network.request.shutdown_request import ShutdownRequest
from tribler.gui.network.request_manager import request_manager
from tribler.gui.utilities import connect

Expand Down Expand Up @@ -238,8 +238,9 @@ def send_shutdown_request(initial=False):
else:
self._logger.warning("Re-sending shutdown request to Tribler Core")

request = ShutdownRequest(shutdown_request_processed)
request_manager.add(request)
request = request_manager.put("shutdown", shutdown_request_processed,
priority=QNetworkRequest.HighPriority)
request.cancellable = False

send_shutdown_request(initial=True)

Expand Down
1 change: 1 addition & 0 deletions src/tribler/gui/network/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(

self.time = time()
self.status_code = 0
self.cancellable = True

def set_manager(self, manager: RequestManager):
self.manager = manager
Expand Down
8 changes: 0 additions & 8 deletions src/tribler/gui/network/request/shutdown_request.py

This file was deleted.

10 changes: 4 additions & 6 deletions src/tribler/gui/network/request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from tribler.gui.defs import BUTTON_TYPE_NORMAL, DEFAULT_API_HOST, DEFAULT_API_PORT, DEFAULT_API_PROTOCOL
from tribler.gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler.gui.network.request.request import Request
from tribler.gui.network.request.shutdown_request import ShutdownRequest
from tribler.gui.utilities import connect


Expand Down Expand Up @@ -173,11 +172,10 @@ def get_message_from_error(d: Dict) -> str:

return json.dumps(d)

def clear(self, skip_shutdown_request=True):
for req in list(self.active_requests):
if skip_shutdown_request and isinstance(req, ShutdownRequest):
continue
req.cancel()
def clear(self):
for request in list(self.active_requests):
if request.cancellable:
request.cancel()

def _drop_timed_out_requests(self):
for req in list(self.active_requests):
Expand Down

0 comments on commit 908fd50

Please sign in to comment.