首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python logging 错误是咋回事 哪位高手能告诉小弟我该如何解决呢

2012-02-04 
python logging 异常是怎么回事 谁能告诉我该怎么解决呢我在Ctrl + C 终止多线程的时候 有的时候会报以下

python logging 异常是怎么回事 谁能告诉我该怎么解决呢
我在Ctrl + C 终止多线程的时候 有的时候会报以下异常 我觉得应该是logging报出的 麻烦各位告诉我解决方法 多谢

logging.conf配置文件:
#logging.conf
[loggers]
keys=root,spider

[handlers]
keys=consoleHandler,rotateFileHandler

[formatters]
keys=simpleFormatter

[formatter_simpleFormatter]
format=[%(asctime)s](%(levelname)s)%(name)s : %(message)s

[logger_root]
level=DEBUG
handlers=consoleHandler,rotateFileHandler

[logger_spider]
level=DEBUG
handlers=consoleHandler,rotateFileHandler
qualname=spider
propagate=0

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_rotateFileHandler]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('../log/spider.log', 'a', 1024 * 1024 * 600, 50)

报的异常:
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
  func(*targs, **kargs)
  File "/usr/local/lib/python2.6/logging/__init__.py", line 1509, in shutdown
[2000-01-11 21:58:49,718](INFO)spider : [taskrunner]:thread exit:task_thd_1
  h.close()
  File "/usr/local/lib/python2.6/logging/__init__.py", line 828, in close
  self.stream.close()
IOError: close() called during concurrent operation on the same file object.
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
  func(*targs, **kargs)
  File "/usr/local/lib/python2.6/logging/__init__.py", line 1509, in shutdown
  h.close()
  File "/usr/local/lib/python2.6/logging/__init__.py", line 828, in close
  self.stream.close()
IOError: close() called during concurrent operation on the same file object.

[解决办法]
对同一个文件对象进行了并发的close操作。在close处判断一下并加锁就行了。

热点排行