Skip to content

Improve retry logic #141

@Malinskiy

Description

@Malinskiy

Current logic for http requests just retries immediately which leads to doing all the retries one after the other https://github.com/jellyfin/mopidy-jellyfin/blob/master/mopidy_jellyfin/http.py#L53

Context: I have an embedded box with mopidy + jellyfin starting during systemd boot. The problem is even though network.target is up the network is not really available at this point for mopidy-jellyfin, hence the HTTP connection might fail.

Jun 04 16:21:20 schiit mopidy[361]: ERROR    2023-06-04 16:21:20,039 [361:MainThread] mopidy_jellyfin.http
Jun 04 16:21:20 schiit mopidy[361]:   Failed to reach Jellyfin public API on try 0 with problem: HTTPSConnectionPool(host='jellyfin.home.XXX', port=443): Max retries exceeded with url: /system/info/public (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f88235da590>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
....
Jun 04 16:21:20 schiit mopidy[361]: ERROR    2023-06-04 16:21:20,046 [361:MainThread] mopidy_jellyfin.http
Jun 04 16:21:20 schiit mopidy[361]:   Failed to reach Jellyfin public API on try 5 with problem: HTTPSConnectionPool(host='jellyfin.home.XXX', port=443): Max retries exceeded with url: /system/info/public (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f88235da590>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

Suggestion: exponential backoff for temporary network failure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions