By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,534 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,534 IT Pros & Developers. It's quick & easy.

file.readlines() and IOError exceptions

P: n/a
Hi everyone,
I currently have a problem with reading one of my files.
Normally I'd read files like so:
overf = 'C:\\overf'
my_overf = open(overf,'r')
contents = my_overf.readlines()

now the file Im trying to read has recently had alot of read/writes from
other users/threads/etc, so every now and again I get a
IOError: [Errno 9] Bad file descriptor
I know this has something to do with not being able to read while some
filehandles are open (or is it?)..I've tried using the following snippet

while my_overf.readline() != '':
except Exception:
d = 0 #do nothing

but it works far slower than normal readlines() there a way to
check the status of this file and wait until the error has gone (i.e
wait until other users/programs are done with it)?

Jul 12 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.