Skip to content

Commit

Permalink
fix for daemon race condition (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLangford authored Jun 6, 2019
1 parent 2cbe61b commit 47be22d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/daemon-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
NAME='vw-daemon-test'

export PATH="vowpalwabbit:../vowpalwabbit:${PATH}"
export PATH="vowpalwabbit:../build/vowpalwabbit:${PATH}"
# The VW under test
VW=`which vw`

Expand Down Expand Up @@ -59,7 +59,6 @@ else
exit 1
fi


# A command (+pattern) that is unlikely to match anything but our own test
DaemonCmd="$VW -t -i $MODEL --daemon $Foreground --num_children 1 --quiet --port $PORT"
# libtool may wrap vw with '.libs/lt-vw' so we need to be flexible
Expand Down Expand Up @@ -142,22 +141,24 @@ fi
# Test on train-set
# OpenBSD netcat quits immediately after stdin EOF
# nc.traditional does not, so let's use -q 1.
#$NETCAT -q 1 localhost $PORT < $TRAINSET > $PREDOUT
$NETCAT -q 1 localhost $PORT < $TRAINSET > $PREDOUT
#wait

# JohnLangford: I'm unable to make the following work on Ubuntu 16.04. Without -q 1, netcat appears to sometimes early terminate with STATUS an empty string.
# However, GNU netcat does not know -q, so let's do a work-around
touch $PREDOUT
( $NETCAT localhost $PORT < $TRAINSET > $PREDOUT; STATUS=$?; echo $STATUS > $NETCAT_STATUS ) &
#touch $PREDOUT
#( $NETCAT localhost $PORT < $TRAINSET > $PREDOUT; STATUS=$?; echo $STATUS > $NETCAT_STATUS ) &
# Wait until we recieve a prediction from the vw daemon then kill netcat
until [ `wc -l < $PREDOUT` -eq 2 ]; do
if [ -f $NETCAT_STATUS ]; then
STATUS=`cat $NETCAT_STATUS`
if [ $STATUS -ne 0 ]; then
echo "$NAME: netcat failed with status code $STATUS"
stop_daemon
exit 1
fi
fi
done
#until [ `wc -l < $PREDOUT` -eq 2 ]; do
# if [ -f $NETCAT_STATUS ]; then
# STATUS=`cat $NETCAT_STATUS`
# if [ $STATUS -ne 0 ]; then
# echo "$NAME: netcat failed with status code $STATUS"
# stop_daemon
# exit 1
# fi
# fi
#done
$PKILL -9 $NETCAT

# We should ignore small (< $Epsilon) floating-point differences (fuzzy compare)
Expand All @@ -176,4 +177,3 @@ case $? in
exit 2
;;
esac

0 comments on commit 47be22d

Please sign in to comment.