[Python-Dev] extremely slow exit for program having huge (45G) dict (python 2.5.2)

Andrew Bennetts andrew-pythondev at puzzling.org
Sun Dec 21 01:15:30 CET 2008


skip at pobox.com wrote:
>> Steve> Unfortunately there are doubtless programs out there that do rely
> Steve> on actions being taken at shutdown.
>> Indeed. I believe any code which calls atexit.register.
>> Steve> Maybe os.exit() could be more widely advertised, though ...
>> That would be os._exit(). Calling it avoids calls to exit functions
> registered with atexit.register(). I believe it is both safe, and
> reasonable programming practice for modules to register exit functions.
> Both the logging and multiprocessing modules call it. It's incumbent on the
> application programmer to know these details of the modules the app uses
> (perhaps indirectly) to know whether or not it's safe/wise to call
> os._exit().

You could call sys.exitfunc() just before os._exit().
-Andrew.


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /