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

logging breakdown

P: n/a

I'm getting strange exception raised using module logging.
It's strange because it happens only sometimes, and it happens
in different places (but always in a logging method).
i.e. this line of code:'SMS sent')

produces following traceback:

Traceback (most recent call last):
File "L:\_progs\python\test\", line 36, in send_sms'SMS sent')
File "L:\Python23\lib\logging\", line 893, in info
apply(self._log, (INFO, msg, args), kwargs)
File "L:\Python23\lib\logging\", line 994, in _log
File "L:\Python23\lib\logging\", line 1004, in handle
File "L:\Python23\lib\logging\", line 1037, in callHandlers
File "L:\Python23\lib\logging\", line 592, in handle
File "L:\Python23\lib\logging\", line 684, in emit
File "L:\Python23\lib\logging\", line 636, in handleError
traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
File "L:\Python23\lib\", line 123, in print_exception
print_tb(tb, limit, file)
File "L:\Python23\lib\", line 69, in print_tb
if line: _print(file, ' ' + line.strip())
File "L:\Python23\lib\", line 13, in _print
IOError: [Errno 9] Bad file descriptor
This is the way I initialize logging:

def initLogger(filename):
log = logging.getLogger('test')
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')

# file
hdlr = logging.FileHandler(filename)

# screen
hdlr = logging.StreamHandler(sys.stdout)


return log

log = initLogger('test.log')

I pass variable "log" to functions requesting it.
My script runs continually, sleeping 1h, doing something, sleeping 1h, etc.
Is it possible that file handler expires or something?

Do I do something wrong?

Marek Augustyn
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.