> [...]
> Simply put:  How do I supply an exit hook for a module (i.e. how do I
> run clean up code before python exits. This is to unlink shared memory
> that will still exist even after python shuts down normally.)
Assign your exit function to sys.exitfunc - it will get called when 
python exits.  (This works whether you explicitly call sys.exit() to 
exit, or the interpreter encounters an <eof>, or whatever.  The exit func 
will not get called, however, if you exit via os._exit().)
>>> def done(): print 'done'
... 
>>> sys.exitfunc = done
>>> sys.exit(0)
done
% 
ken
ken.manheimer@nist.gov, 301 975-3539