On 09/01/11 22:05, Jim Meyering wrote: > diff --git a/tests/du/move-dir-while-traversing > b/tests/du/move-dir-while-traversing
> +# We use a python-inotify script, so... > +python -m pyinotify -h > /dev/null \ > + || skip_ 'python-inotify package not installed' A small point is that error is a bit fedora specific. The package is python-pyinotify on debian/ubuntu for example. > + > +# Move a directory "up" while du is processing its sub-directories. > +# While du is processing a hierarchy .../B/C/D/... this script > +# detects when du opens D/, and then moves C/ "up" one level > +# so that it is a sibling of B/. > +# Given the inherent race condition, we have to add enough "weight" > +# under D/ so that in most cases, the monitor performs the single > +# rename syscall before du finishes processing the subtree under D/. > + > +cat <<'EOF' > inotify-watch-for-dir-access.py > +#!/usr/bin/env python > +from pyinotify import * I generally don't include everything from a module, to keep the namespace clean. I'd do instead: import pyinotify as pn import os,sys ... > +dir = sys.argv[1] > +dest_parent = os.path.dirname(os.path.dirname(dir)) > +dest = os.path.join(dest_parent, os.path.basename(dir)) > + > +class ProcessDir(ProcessEvent): > + > + def process_IN_OPEN(self, event): > + os.rename(dir, dest) > + sys.exit(0) > + > + def process_default(self, event): > + pass > + > +wm = WatchManager() > +notifier = Notifier(wm) > +wm.watch_transient_file(dir, IN_OPEN, ProcessDir) > +print 'started' The above print is buffered by default. As we're using it for synchronization I'd sys.stdout.write('started\n') sys.stdout.flush() > +notifier.loop() > +EOF > +chmod a+x inotify-watch-for-dir-access.py > + > +long=d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z > +t=T/U > +mkdir -p $t/3/a/b/c/$long d2 || framework_failure > +timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg & > + > +# Wait for the watcher to start... > +nonempty() { test -s start-msg && return 0; sleep $1; } > +retry_delay_ nonempty .1 5 I think the above may iterate only once? How about: nonempty() { test -s start-msg || { sleep $1; return 1; } } retry_delay_ nonempty .1 5 || framework_failure > + > +# The above delay is insufficient in ~50% of my trials. > +# Sometimes, when under heavy load, a parallel "make check" would > +# fail this test when sleeping just 0.1 seconds here. > +sleep 1 Hopefully this extra sleep is not required now Nice fix BTW! cheers, Pádraig. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org