windows - Python Time based rotating file handler for logging -


while using time based rotating file handler.getting error

  os.rename('logthred.log', dfn)   windowserror: [error 32] process cannot access file because   being used process 

config :

[loggers] keys=root  [logger_root] level=info handlers=timedrotatingfilehandler  [formatters] keys=timedrotatingformatter  [formatter_timedrotatingformatter] format = %(asctime)s %(levelname)s %(name)s.%(functionname)s:%(lineno)d % (output)s datefmt=%y-%m-%d %h:%m:%s  [handlers] keys=timedrotatingfilehandler  [handler_timedrotatingfilehandler] class=handlers.timedrotatingfilehandler level=info formatter=timedrotatingformatter args=('d:\\log.out', 'm', 2, 0, none, false, false) 

want achieve time based rotating file handler , multiple process can write same log file.in python,i didn't find thing can resolve issue.

i have read discussion on issue (python issues).

any suggestion can resolve issue.

found solution : problem in python 2.7 whenever create child process file handles of parent process inherited child process causing error.we can block inheritance using code.

if sys.platform == 'win32': ctypes import * import msvcrt  __builtins__open = __builtins__.open  def __open_inheritance_hack(*args, **kwargs):     result = __builtins__open(*args, **kwargs)     handle = msvcrt.get_osfhandle(result.fileno())     if filename in args: #which filename handle don't want give child process.         windll.kernel32.sethandleinformation(handle, 1, 0)     return result  __builtins__.open = __open_inheritance_hack 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -