what is the best way to dynamically redisplay a graph

I want to use Graphviz to dynamically update a (near) real-time display of the threads that are part of a process (think parent-child relationships graph).  If a new thread is spawned, it will exist for a minimum of many seconds.  The thread may then terminate or it may remain around if there is additional work for it to do.  Therefore,  I don't need to worry about sub-1-second renderings of the graph.
What is the best way to do this with Graphviz?  lefty?
Way (way) back in 1995, I used lefty for a similar purpose -- to display near real-time call state transitions, for the AT&T Merlin Legend PBX.  I dug up my old lefty script (yes, I still had it!), and two of us started hacking away at it.  We got it to work somewhat under cygwin, but we'd like to run native on Windows (XP today, Windows 7 very soon).  
I'm having problems with lefty's openio() on XP.  I opened a file for reading, and turned monitor()ing 'on', but lefty doesn't seem to notice when I append to the file.  (I write to this file when I want to signal lefty that it is time to reload the graph, because there has been a change to the number of threads in the process).
Can I signal lefty some other way?
Since I couldn't get that to work, I figured I would settle for the following: put lefty in a loop, and reload the graph every 2 seconds.  That didn't work either, since lefty's sleep function doesn't seem to work on Windows XP either.
Any advice or suggestions?
6/6/2011 update:  I am now able to signal lefty.  The issue seems to be that lefty will call the monitorfile callback even for mouse movements.  My working lefty script now looks like this:
monitorfile_fd = 0;
# ===============================================================
# This function is called by lefty whenever there is file activity.
# (It also seems to be called whenever the mouse moves in the lefty window!)
collector.monitorfile = function (data) {
local vt, gt, s;
s = 0; # seems to be needed, since readline() returns ??? if this
# method was called because of a mouse movement
s = readline(monitorfile_fd);     # read from the file
if(s == 0) {
return;
}
if (s == "update") {
echo ('update received');
vt = dotty.views[3]; # assume graph is widget 3
gt = dotty.graphs[vt.gtid];
# reload the dot file and redraw/graph it
gt.loadgraph (gt, gt.name, gt.type, gt.graph, 1);  # from dotty_ui.lefty
return;
}
if (s == "quit") {
echo ('quit received');
exit();
}
echo( concat ('unknown msg=' , s));
};
# ======================================================================
collector.init = function (filename) {
dotty.init ();
# can't seem to get lefty to launch collector.pl:
#   monitorfile_fd = openio ('pipe', 'collector.pl', 'r');
# but at least we can get it to monitor a file.  We'll write to that file as a
# way to signal lefty to reload the dotty file, or to quit
monitorfile_fd = openio ('file', filename, 'r');
if(monitorfile_fd >= 0) {
# file open ok
} else {
echo ('error opening file ', filename);
return;
}
monitor('on', monitorfile_fd);
# use collector's monitorfile function
monitorfile = collector.monitorfile;
};
# ----------------------------------------------------------------------
collector.main = function () {
collector.init ('collector.lefty.monitorfile');
dotty.createviewandgraph ('collector.dot', 'file', null, null);
txtview ('off');
};
 
 

Recent comments