[IPython-user] ipython logfile blocked (logging module)

Robert Kern robert.kern@gmail....
Tue Feb 17 15:38:19 CST 2009

On 2009-02-17 15:26, Tim Michelsen wrote:
> Hello,
> I am employing the python logging module in my script.
> I set the logger to write to a log file.
> When I run the script (%run myscript.py) everthing works fine.
> But when I re-run it, I get a file access error telling that the logfile
> is in use.
> I always need to exit Ipython and restart IPython in order to run the
> script again. Is there an option to prevent this?
> I have put
> logging.shutdown() at the end of my script.

Don't set up the loggers in your script. Put it in a separate script; %run it 
once at the start of your session; then %run your main script any number of times.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the IPython-user mailing list