Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
We must check the output string for True or False along with the retu…
Browse files Browse the repository at this point in the history
…rn code.

patch to cancel a request to help prevent forcing a full bucket iteration to have the request time out.
  • Loading branch information
buzztroll committed Jan 26, 2012
1 parent 6dc2d57 commit 273c00b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
49 changes: 30 additions & 19 deletions control/bin/ltclient.sh
Expand Up @@ -47,54 +47,65 @@ do
if [ $cnt -gt $thresh ]; then
echo "ltclient checking in..."
thresh=30
cnt=0
out=`ssh -p $port $userhost "$remoteexe" --nonblock --reattach "$rid"`
if [ $? -ne 0 ]; then
rc=$?
msgrc=`echo $out | awk -F , '{ print $1 }'`
done=`echo $out | awk -F , '{ print $2 }'`
message=`echo $out | awk -F , '{ print $3 }'`
echo $out
if [ $rc -ne 0 ]; then
ssh_error_cnt=`expr $ssh_error_cnt + 1`
echo $out
echo "ssh failed, we allow this to happen a few times"
if [ $ssh_error_cnt -gt 3 ]; then
exit 1
fi
else
rc=`echo $out | awk -F , '{ print $1 }'`
done=`echo $out | awk -F , '{ print $2 }'`
message=`echo $out | awk -F , '{ print $3 }'`
echo $out
if [ "X$done" == "XTrue" ]; then
exit $rc
fi
# once it succeds we can reset the error counter
ssh_error_cnt=0
fi

if [ "X$done" == "XTrue" ]; then
echo "exiting"
exit $rc
fi
fi

if [ ! -e $localpath_basedir ]; then
echo "the directory for the receiving file does not exist"
echo "this likely means that the request was terminated"
ssh -p $port $userhost "$remoteexe" --nonblock --cancel --reattach "$rid"
echo $?
exit 2
fi
done

echo "$localpath exists"
echo "running a blocking query"
done=0
done="False"
ssh_error_cnt=0
# if we get here the file exists but we have not yet received word of
# suceess from the head node. run a blocking query
while [ $done -eq 0 ];
while [ "X$done" == "XFalse" ];
do
ssh -p $port $userhost "$remoteexe" --reattach "$rid"
out=`ssh -p $port $userhost "$remoteexe" --reattach "$rid"`
rc=$?
done=`echo $out | awk -F , '{ print $2 }'`
message=`echo $out | awk -F , '{ print $3 }'`
echo $out

echo "------> $done"

if [ $rc -ne 0 ]; then
ssh_error_cnt=`expr $ssh_error_cnt + 1`
if [ $ssh_error_cnt -gt 3 ]; then
done=1
else
sleep 0.$RANDOM
if [ "X$done" == "XFalse" ]; then
ssh_error_cnt=`expr $ssh_error_cnt + 1`
if [ $ssh_error_cnt -gt 3 ]; then
done="True"
else
sleep 0.$RANDOM
fi
fi
else
done=1
done="True"
fi
done
echo "exiting with $rc"
Expand Down
8 changes: 7 additions & 1 deletion lantorrent/pylantorrent/request.py
Expand Up @@ -27,6 +27,8 @@ def setup_options(argv):
all_opts.append(opt)
opt = cbOpts("reattach", "a", "Reattach", None)
all_opts.append(opt)
opt = cbOpts("cancel", "c", "Cancel", False, flag=True)
all_opts.append(opt)

(o, args) = pylantorrent.parse_args(parser, all_opts, argv)
return (o, args, parser)
Expand Down Expand Up @@ -167,7 +169,7 @@ def main(argv=sys.argv[1:]):
sz = -1
done = False
message = ""
if o.reattach == None:
if o.reattach is None:
(rid, sz) = request(args, con)
try:
(done, rc, message) = is_done(con, rid)
Expand All @@ -177,6 +179,10 @@ def main(argv=sys.argv[1:]):
message = "Check on status later, db not ready for polling"
else:
rid = o.reattach
if o.cancel:
delete_rid(con, rid)
return 0

(done, rc, message) = is_done(con, rid)

if not o.nonblock and not done:
Expand Down

0 comments on commit 273c00b

Please sign in to comment.