[Pythonmac-SIG] Wierd Error/Bug in MacPython 2.0
Chris Barker
chrishbarker@home.net
Fri, 08 Jun 2001 13:40:51 -0700
Jack Jansen wrote:
> I'd say just rerun the whole computation that generates the output file. The
> problem may have occurred earlier than the close() but may only become visible
> at that point.
Actually, it's reading an input file, but that makes little difference.
Actually, the code around the file closing is pretty darn simple, it's
essentially:
file = open(filename,'rb') # open as a binary file
for i in range(HeaderData['NumLines']):
file.readline()
data = fromstring(file.read(NumBytes*NumTimesteps*NumLEs),UnsignedInt8)
file.close()
So I'll try wrapping that in a try: except (or maybe the whole function
this is in)
> The second try/except is a trick to clear the stacktrace: it will still
> contain open file objects for the input and output file, and you want to get
> rid of them before trying again.
hmmm. I don't quite understand this, but I'll take your word for it.
> I wouldn't do a "while 1:" because there are many reasons the thing could
> fail. If it fails for the silly-close-bug reason once every 400 times this
> code will make it fail only once very 16000 times, so that should be good
> enough.
Good point. I may wrap it in a "for i in range(10):" to really reduce my
odds!
Thanks for your ideas, I'll give them a try.
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------