Skip to content

Commit

Permalink
Merge pull request #7054 from kozlovsky/fix/event_request_manager_tim…
Browse files Browse the repository at this point in the history
…eout

Fix CoreConnectTimeoutError by calculating the correct timeout for the request
  • Loading branch information
kozlovsky authored Sep 20, 2022
2 parents 4d953de + 3b64aa4 commit e84fb74
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/tribler/gui/event_request_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, api_port, api_key, error_handler):
self.network_errors = make_network_errors_dict()

self.connect_timer.setSingleShot(True)
connect(self.connect_timer.timeout, self.connect)
connect(self.connect_timer.timeout, self.reconnect)

self.notifier = notifier = Notifier()
notifier.add_observer(notifications.events_start, self.on_events_start)
Expand Down Expand Up @@ -166,6 +166,15 @@ def on_finished(self):
self.connect_timer.start(RECONNECT_INTERVAL_MS)

def connect(self, reschedule_on_err=True):
if reschedule_on_err:
self._logger.info(f"Set event request manager timeout to {CORE_CONNECTION_TIMEOUT} seconds")
self.start_time = time.time()
self._connect(reschedule_on_err)

def reconnect(self, reschedule_on_err=True):
self._connect(reschedule_on_err)

def _connect(self, reschedule_on_err):
self._logger.info(f"Connecting to events endpoint ({'with' if reschedule_on_err else 'without'} retrying)")
if self.reply is not None:
self.reply.deleteLater()
Expand Down

0 comments on commit e84fb74

Please sign in to comment.