Skip to content

Varia fails to start after disabling torrent seeding: TypeError converting float to long in libtorrent #272

Description

@edmundlaugasson

Description

Varia fails to start after torrent seeding has been disabled in the application settings.

The application worked normally immediately after installation. I then disabled torrent seeding, closed Varia, and later tried to start it again. From that point on, Varia crashed during startup every time.

Running Varia from a terminal shows that the crash occurs in set_lt_seeding() when the libtorrent settings are applied:

TypeError: No registered converter was able to produce a C++ rvalue of type long from this Python object of type float

Re-enabling torrent seeding in Varia's configuration makes the application start normally again.

Environment

  • OS: Linux Mint 22.3
  • Desktop environment: Xfce
  • Architecture: x86_64
  • Varia installation: Flatpak / Flathub
  • Varia version: v2026.8.5
  • Flatpak application ID: io.github.giantpinkrobots.varia

Varia is launched as:

/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=varia --file-forwarding io.github.giantpinkrobots.varia

Steps to reproduce

  1. Install Varia from Flathub.
  2. Start Varia.
  3. Confirm that Varia starts normally.
  4. Open Varia's settings/preferences.
  5. Disable torrent seeding.
  6. Close Varia.
  7. Start Varia again.

Actual behavior

Varia does not open.

The aria2 backend starts, but Varia then crashes while applying the libtorrent settings.

Terminal output:

Selected JS Runtime name: deno

08/17 00:59:31 [WARN] Neither --rpc-secret nor a combination of --rpc-user and --rpc-passwd is set. This is insecure. It is extremely recommended to specify --rpc-secret with the adequate secrecy or now deprecated --rpc-user and --rpc-passwd.

08/17 00:59:31 [NOTICE] IPv4 RPC: listening on TCP port 6801

08/17 00:59:31 [NOTICE] IPv6 RPC: listening on TCP port 6801
Traceback (most recent call last):
  File "/app/share/varia/varia/variamain.py", line 604, in on_activate
    self.win = MainWindow(application=app, variaapp=self, appdir=appdir, appconf=appconf, first_run=first_run, aria2cexec=aria2cexec, ffmpegexec=ffmpegexec, sevenzexec=sevenzexec, jsruntimeexec=jsruntimeexec, issnap=issnap, pkgdatadir=pkgdatadir)
               ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/share/varia/varia/variamain.py", line 107, in __init__
    set_lt_seeding(self) # We set this again after adding the downloads
    ~~~~~~~~~~~~~~^^^^^^
  File "/app/share/varia/varia/download/communicate.py", line 113, in set_lt_seeding
    self.ltsession.apply_settings(settings)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: No registered converter was able to produce a C++ rvalue of type long from this Python object of type float
*** Varia has stopped ***

The aria2 RPC warning appears before the crash, but does not appear to be the cause: aria2 successfully starts listening on both IPv4 and IPv6, and the fatal exception occurs later in set_lt_seeding() / libtorrent.apply_settings().

Expected behavior

Disabling torrent seeding should prevent or limit seeding as intended, but Varia should continue to start normally.

Closing and reopening the application should not result in a startup crash.

Workaround

Re-enabling torrent seeding in the Varia configuration fixes the problem immediately.

After changing:

torrent_seeding_enabled = "0"

back to:

torrent_seeding_enabled = "1"

Varia starts normally again.

For now, keeping torrent seeding enabled and manually stopping completed torrents also avoids the crash.

Suspected cause

The exception appears to correspond directly to the set_lt_seeding() implementation in:

src/download/communicate.py

When torrent seeding is disabled, the current code contains:

if self.appconf["torrent_seeding_enabled"] == '0':
    settings["unchoke_slots_limit"] = 0
    settings["num_optimistic_unchoke_slots"] = 0
    settings["share_ratio_limit"] = 0.0
    settings["upload_rate_limit"] = 1

and then:

self.ltsession.apply_settings(settings)

The important line appears to be:

settings["share_ratio_limit"] = 0.0

0.0 is a Python float.

However, libtorrent's settings_pack::share_ratio_limit is an integer (int) setting. This matches the exception exactly:

No registered converter was able to produce a C++ rvalue
of type long from this Python object of type float

When seeding is enabled, Varia instead uses:

settings["share_ratio_limit"] = -1

which is an integer and does not trigger the crash.

The same 0.0 assignment is currently present in both the main and next branches.

Possible fix

Unless there is a reason for this value to be a floating-point number, a minimal fix would appear to be changing:

settings["share_ratio_limit"] = 0.0

to:

settings["share_ratio_limit"] = 0

so that the value passed to libtorrent has the expected integer type.

The exact value should of course be adjusted according to the intended libtorrent semantics, but the immediate crash appears to result from passing a Python float to an integer libtorrent setting.

Additional observation

This explains why the problem initially looked unusual:

  • Varia worked immediately after installation.
  • The application was closed normally.
  • It failed to start afterwards.
  • Restoring torrent_seeding_enabled to "1" made it start again.

So the Flatpak installation itself does not appear to be damaged. The startup failure depends on the saved torrent-seeding setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions