I have a python script whihc logs in some file.
This script calls some outside bat file which also logs in same file. The out side program complains that it cant get lock on log file.
The python script has lock to log file so it has to temporarily release. So before calling outside program, I call logging.shutdown, It works fine and out side program can log in log file but once control is returned to python script, I try to acquire another logging.getLogger() but it throws exception "Error: cannot release un-aquired lock" and script exits. The weird thing is that , the line 'i m fine is printed twice before script exits. I am printing it only once in my script. Any idea what is going on and how can I resolve this issue.
Here is my code snippet
#some python work logging.shutdown() process = subprocess.Popen(...) process.wait() configure_logger() logger.info(' i m fine') #some more python work def configure_logger(): global logger logging.basicConfig(level=logging.DEBUG, format="[%(asctime)s '' %(levelname)s] [%(name)s] %(message)s", datefmt='%m-%d-%Y %H:%M:%S:%MS', filename=LOG_FILENAME) console = logging.StreamHandler() console.setLevel(logging.INFO) print ' i m trying 5' logger = logging.getLogger('vum_backup') logger.addHandler(console)