closing all files when program terminates

Steve Holden sholden at holdenweb.com
Fri Nov 3 23:39:18 EST 2000


jschmitt at vmlabs.com wrote:
> 
> I run this Python program that creates files.  If I use CONTROL-C to
> abort the Python program, I can't delete the files the Python program
> opens.  Win2K says that there has been a sharing violation.  Is there a
> way to close/release all file resources that have opened when the
> program terminates unexpectedly?
> 
> Thanks.
> 
> John
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

I'm sure those with a better grasp of the internals will come up with
all kinds of esoterica, but have you considered simply trapping the
KeyboardInterrupt (?) event and closing the files before exiting?

As long as your program isn't blocked waiting for some event that never
happens (such as a lost reply to a UDP socket) you should be in good
shape.

regards
 Steve
-- 
Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/





More information about the Python-list mailing list