open function fail after running a day
Vinay Sajip
vinay_sajip at yahoo.co.uk
Thu Jun 7 13:13:43 EDT 2007
On Jun 7, 3:33 pm, alexteo21 <alexte... at yahoo.com> wrote:
> I have created a script using python that will batch process data
> files every hour
> The script is running on Solaris. Python version 2.3.3
>
> t=open(filename,'rb')
> data=t.read()
> #processing data...
> t.close()
Try the following approach:
t=open(filename,'rb')
try:
data=t.read()
#processing data...
finally:
t.close()
and see if that improves matters. If you want to add logging for a
quick check, then...
import logging
t=open(filename,'rb')
try:
data=t.read()
#processing data...
except:
logging.exception("Failed to process file %r", filename)
finally:
t.close()
Regards,
Vinay Sajip
More information about the Python-list
mailing list