Konstantin Sobolev 5c71e2f4bf Fix: update token in blocking task
* attempt to fix https://github.com/hrkfdn/ncspot/issues/1358

mpris runs inside `tokio::runtime.spawn`. At some point it hits `metadata_changed->WebApi::track->api_with_retry`, which gets 401 response and tries to update the token.

This goes into `update_token`, which at a certain point calls *blocking* `token_rx.recv()`. Tokio runtime is not happy about that, as it uses the same thread for the `run_loop` in the worker. That's why `tokio::select!` doesn't work, we're essentially deadlocking, so the worker never pick up `RequestToken` command and `update_token` block forever.

Here I'm changing `update_token` to wrap `recv` in `spawn_blocking`, which makes `update_token` return a `JoinHandle`, on which the caller has to await. This doesn't work nicely in case of mpris though, as it is not an async function, and I don't know how to make it async as it goes through the dbus `metadata_changed` interface. My best effort here is to do `and_then`, which seems to work, but I'm not confident that's the right approach.

* fmt

* move token_rx.recv inside spawn_blocking
2024-02-17 12:59:23 +01:00
2023-03-06 21:55:19 +01:00
2023-03-20 23:00:19 +01:00
2024-02-17 12:59:23 +01:00
2023-12-16 18:34:43 +01:00
2019-03-13 13:56:30 +01:00
2021-12-27 09:32:16 +01:00

ncspot logo

An ncurses Spotify client written in Rust using librespot

Crates.io Gitter

ncspot search tab

ncspot is an ncurses Spotify client written in Rust using librespot. It is heavily inspired by ncurses MPD clients, such as ncmpc. My motivation was to provide a simple and resource friendly alternative to the official client as well as to support platforms that currently don't have a Spotify client, such as the *BSDs.

ncspot only works with a Spotify premium account as it offers features that are not available for free accounts.

Features

  • Support for tracks, albums, playlists, genres, searching...
  • Small resource footprint
  • Support for a lot of platforms
  • Vim keybindings out of the box
  • IPC socket for remote control
  • Automatic authentication using a password manager

Installation

ncspot is available on macOS (Homebrew), Windows (Scoop), Linux (native package and Flathub) and the BSD's. Detailed installation instructions for each platform can be found here.

Configuration

A configuration file can be provided. The default location is ~/.config/ncspot. Detailed configuration information can be found here.

Building

Building ncspot requires a working Rust installation and a Python 3 installation. To compile ncspot, run cargo build. For detailed instructions on building ncspot, there is more information here.

Packaging

Information about provided files, how to generate some of them and current package status accross platforms can be found here.

Description
No description provided
Readme 3.9 MiB
Languages
Rust 100%