473,587 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open function fail after running a day

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()

The script is working fine on the day of execution.
It is able to process the data files very hour. However, the
processing fail one day later i.e. the date increment by 1.

Traceback (most recent call last):
File "./alexCopy.py", line 459, in processRequestM odule
sanityTestSteps (reqId,model)
File "./alexCopy.py", line 699, in sanityTestSteps
t = open(filename, 'rb')
IOError: [Errno 24] Too many open files:

I have explicitly closed the file. Is there something else I need to
do?

Appreciate your comments

Jun 7 '07 #1
5 1534
In article <11************ **********@n15g 2000prd.googleg roups.com>,
alexteo21 <al*******@yaho o.comwrote:
The script is working fine on the day of execution.
It is able to process the data files very hour. However, the
processing fail one day later i.e. the date increment by 1.

Traceback (most recent call last):
File "./alexCopy.py", line 459, in processRequestM odule
sanityTestSteps (reqId,model)
File "./alexCopy.py", line 699, in sanityTestSteps
t = open(filename, 'rb')
IOError: [Errno 24] Too many open files:

I have explicitly closed the file. Is there something else I need to
do?
Sounds like the .close() isn't getting executed as you think. Try using
the logging module to log a line immediately before each open and close
so that you can ensure you're really closing all the files.
Alternatively, some other bit of code my be the guilty party. A utility
like fstat can show you who has files open.

Good luck

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Jun 7 '07 #2
On Jun 7, 3:33 pm, alexteo21 <alexte...@yaho o.comwrote:
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.excepti on("Failed to process file %r", filename)
finally:
t.close()

Regards,

Vinay Sajip

Jun 7 '07 #3
Try the following:

import logging

t=open(filename ,'rb')
try:
data=t.read()
#processing data...
except:
logging.excepti on("Failed to process %r", filename)
finally:
t.close()


Jun 7 '07 #4
Try the following (Python 2.5.x):

import logging

t=open(filename ,'rb')
try:
data=t.read()
#processing data...
except:
logging.excepti on("Failed to process %r", filename)
finally:
t.close()

For earlier versions of Python, you will need to nest the try blocks:

import logging

t=open(filename ,'rb')
try:
try:
data=t.read()
#processing data...
except:
logging.excepti on("Failed to process %r", filename)
finally:
t.close()

Regards,
Vinay Sajip

Jun 7 '07 #5
Sorry for the multiple posts. I kept getting network errors and it
looked like the posts weren't getting through.

Regards,

Vinay

Jun 8 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
11211
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but...
3
24677
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The situation is: A main window opens child windows one at a time as the user requests, each with its own name. The user may click in any child window...
23
6395
by: Markus | last post by:
Hi, i have this problem: Sometimes, i can't reproduce, if i click on an small image on the website, the popup _AND_ an other Tab in firefox open. Here are the linkcode: <div align="center">
5
2624
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char* replace){ char* result; size_t l = strlen(source), r = strlen(replace), i; int number_of_replaces = 0; for(i = 0; i < l; i++){ if(source == search)
21
3566
by: Joakim Hove | last post by:
Hello, I have implemented a small library with a function a datatype to manage temporary storage, and handle out correctly casted storage. The function to get a double pointer is for instance: double * work_get_double(work_type *work, size_t size) {} Now, if the work area is not sufficiently large, the function fails,
2
3189
by: Jonathan Trevor | last post by:
Hi, For the last couple of releases of a product we're developing we've been running to very wierd behavior from IE and our ASP.NET web application which serves up various types of files and I'm getting very frustrated in trying to solve it! We content we are serving up is potentially sensitive and therefore we DO NOT want it cached on...
10
2366
by: Gunnar G | last post by:
I'm having problem reading from the beginning of a file. Here is the code (more or less) ifstream codefin; ofstream codefout; while (not_annoyed)
5
11192
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end. Ocz, if the file is not exist(e.g. another day), it will creates the file first.
6
34633
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case I would ignore processing that particular file and move to next file. How can I check whether the file is open or not? I tried os.stat and...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.