Update connection verification-related logic

This commit is contained in:
codeking 2024-10-01 05:45:43 +02:00
parent 6a6210ecb7
commit b34a6f8935
2 changed files with 4 additions and 4 deletions

View file

@ -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
))

View file

@ -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'))