Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

We must check the output string for True or False along with the retu…

…rn code.

patch to cancel a request to help prevent forcing a full bucket iteration to have the request time out.
  • Loading branch information...
commit 273c00b580229b71cabe14ab69715937840ac641 1 parent 6dc2d57
@buzztroll buzztroll authored
Showing with 37 additions and 20 deletions.
  1. +30 −19 control/bin/ltclient.sh
  2. +7 −1 lantorrent/pylantorrent/request.py
View
49 control/bin/ltclient.sh
@@ -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"
View
8 lantorrent/pylantorrent/request.py
@@ -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)
@@ -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)
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.