"Timeout was reached" message during torrent done script run

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
intuited
Posts: 10
Joined: Mon Feb 22, 2010 9:41 pm

"Timeout was reached" message during torrent done script run

Post by intuited »

I'm able to use the

Code: Select all

--torrent-done-script
option to specify a script to run when a torrent completes.

I'm using a bash script, and calling

Code: Select all

exec >> logfile
so that it will log its output.

It is supposed to add the oldest of the .torrent files in a queue directory.

However, when it runs, I just get output like this:

Code: Select all

[02:53:33.549] transmission-remote: (http://localhost:1234/transmission/rpc) Timeout was reached
The port is the correct one for my running transmission-daemon instance.

When I run the script manually, even immediately after a failed launching of the script by transmission-daemon, it works consistently without problems.

The script is not using the transmission environment variables at all.

Here's my script:

Code: Select all

#!/bin/bash
TORRENT_DIR=~/Downloads/torrents/%queue;
ADDED_DIR="$TORRENT_DIR/%added";

TRANSMISSION_REMOTE=/usr/bin/transmission-remote;

LOG_FILE=~/var/log/transmission-daemon/add-least-recent.log;

exec >> "$LOG_FILE" 2>&1;

echo;
echo "{{{ $(date --rfc-3339=s | tr \  T)	add-least-recent called.";

# Echoes the number of the last torrent added.
function last_added {
  $TRANSMISSION_REMOTE 1234 -l | tail -2 | head -1 | sed 's/^\s*\([0-9]\+\).*/\1/';
}

oldest="$(ls -tr "$TORRENT_DIR"/*.torrent | head -1)" && \
  $TRANSMISSION_REMOTE 1234 -a "$oldest" && \
  mv "$oldest" "$ADDED_DIR" && \
  $TRANSMISSION_REMOTE 1234 -t"$(last_added)" -s -Bn -pr20;

echo '}}}';
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: "Timeout was reached" message during torrent done script

Post by gunzip »

if you're running an old version of TR you may be seeing this bug:

https://trac.transmissionbt.com/ticket/3764

which was fixed in Transmission 2.20 . so either upgrade, or as a temporary workaround do this to your script:

Code: Select all

#!/bin/bash
{
<your script>
} &
otherwise old versions will hangup when invoking the transmission-remote command.
intuited
Posts: 10
Joined: Mon Feb 22, 2010 9:41 pm

Re: "Timeout was reached" message during torrent done script

Post by intuited »

Looks like that's it — I'm running 2.05, still the current version in ubuntu 10.10. Thanks for the tip. I guess I can work around it by firing the action in a subshell.
intuited
Posts: 10
Joined: Mon Feb 22, 2010 9:41 pm

Re: "Timeout was reached" message during torrent done script

Post by intuited »

Okay, this seems to work. My new script:

Code: Select all

#!/bin/bash
TORRENT_DIR=~/Downloads/torrents/%queue;
ADDED_DIR="$TORRENT_DIR/%added";

TRANSMISSION_REMOTE=/usr/bin/transmission-remote;

LOG_FILE=~/var/log/transmission-daemon/add-least-recent.log;

# Do everything in a subshell.
# This is needed under some versions of transmission-daemon < 2.20
# because https://trac.transmissionbt.com/ticket/3764
# blocks reentrance into the transmission library during script handling.
(

  echo;
  echo "{{{ $(date --rfc-3339=s | tr \  T)	add-least-recent called.";

  function tre {
    $TRANSMISSION_REMOTE 1234 "$@";
  }

  # Echoes the number of the last torrent added.
  function last_added {
    tre -l | tail -2 | head -1 | sed 's/^\s*\([0-9]\+\).*/\1/';
  }

  { oldest="$(ls -tr "$TORRENT_DIR"/*.torrent | head -1)" &&
    { tre -a "$oldest" || { sleep 10; tre -a "$oldest"; }; } &&
    mv "$oldest" "$ADDED_DIR" &&
    tre -t"$(last_added)" -s -Bn -pr20; }

  echo '}}}';

) >> "$LOG_FILE" 2>&1 &
Post Reply