This message bounced (perhaps sent from unsubscribed address).
-------------------------------------------------------
From: Dav Clark <[email protected]>
To: [email protected]
Date: Friday 23:40:25
> Hi,
>
> I have a program that uses pytables, and I was wondering if I could
> get a pointer to where in the code you deal with exit handling. for
> example, when a program crashes, I get a message like the following:
>
> Closing remaining open files: testing02/raw_pressure.h5... done
>
> I'd like to be able to customize this behavior, as well as perhaps
> copy this functionality for other parts of my code.
The responsible of this behaviour is the tables.file.close_open_files()
function that is being registered via atexit.register() Python function.
Although you can't de-register already registered cleanup functions, you can
register new ones to tailor the existing behaviour. For example, if you
register this one:
def my_close_open_files(verbose):
open_files = tb.file._open_files
are_open_files = len(open_files) > 0
if verbose and are_open_files:
print >> sys.stderr, "Closing remaining open files:",
for fileh in open_files.keys():
if verbose:
print >> sys.stderr, "%s..." % (fileh.filename,),
fileh.close()
if verbose:
print >> sys.stderr, "done",
if verbose and are_open_files:
print >> sys.stderr
import sys, atexit
atexit.register(my_close_open_files, False)
then, you won't get the closing messages anymore because the new registered
function is executed before the existing one. If you want the messages back
again, just set the verbose parameter to true.
Hope that helps,
--
Francesc Alted
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users