From b34a6f893513b3c63c330e2310ae4b1a15345591 Mon Sep 17 00:00:00 2001 From: codeking Date: Tue, 1 Oct 2024 05:45:43 +0200 Subject: [PATCH] Update connection verification-related logic --- core/controllers/ConnectionController.py | 6 +++--- main.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/controllers/ConnectionController.py b/core/controllers/ConnectionController.py index 921b900..91fdc74 100644 --- a/core/controllers/ConnectionController.py +++ b/core/controllers/ConnectionController.py @@ -266,16 +266,16 @@ class ConnectionController: @staticmethod def await_connection(port_number: int, connection_observer: Optional[ConnectionObserver] = None): - maximum_amount_of_retries = 10 + maximum_number_of_attempts = 5 retry_interval = 5.0 - for retry_count in range(maximum_amount_of_retries): + for retry_count in range(maximum_number_of_attempts): if connection_observer is not None: connection_observer.notify('connecting', dict( retry_interval=retry_interval, - maximum_amount_of_retries=maximum_amount_of_retries, + maximum_number_of_attempts=maximum_number_of_attempts, attempt_count=retry_count + 1 )) diff --git a/main.py b/main.py index 7066671..16968ef 100644 --- a/main.py +++ b/main.py @@ -38,7 +38,7 @@ if __name__ == '__main__': application_version_observer.subscribe('downloading', lambda event: print(f'Downloading {ApplicationController.get(event.subject.application_code).name}, version {event.subject.version_number}...\n')) client_observer.subscribe('synchronizing', lambda event: print('Synchronizing...\n')) - connection_observer.subscribe('connecting', lambda event: print(f'[{event.subject.get("attempt_count")}/{event.subject.get("maximum_amount_of_retries")}] Performing connection attempt...\n')) + connection_observer.subscribe('connecting', lambda event: print(f'[{event.subject.get("attempt_count")}/{event.subject.get("maximum_number_of_attempts")}] Performing connection attempt...\n')) invoice_observer.subscribe('retrieved', lambda event: print(f'\n{pprint.pp(event.subject)}\n')) invoice_observer.subscribe('processing', lambda event: print('A payment has been detected and is being verified...\n'))