Alan Baljeu
http://www.collaborative-systems.org
Intelligent software that works _with_ you.



----- Forwarded Message ----
From: Alan Baljeu <[EMAIL PROTECTED]>
To: Mike Driscoll <[EMAIL PROTECTED]>
Sent: Friday, November 14, 2008 2:06:26 PM
Subject: Re: automatic reload

I thought I was reading something specific was made for unittest, although I 
can't find it now.  TurboGears I don't know much about.  I'm concerned its 
reload is specialized for a certain type of file (page generators?) and might 
not be suitable in general.


The other option I was suggessting PyInitialize and Py_Finalize.  Finalize 
comes with a scary list of issues, which basically say things may fail and 
memory may leak.  I notice also Py_NewInterpreter/Py_EndInterpreter does about 
the same thing for me.  Maybe that's the way to go.  But these caveats scare me:



Also note that the use of this functionality is incompatible with extension
modules such as PyObjC and ctypes that use the PyGILState_* APIs (and
this is inherent in the way the PyGILState_* functions work).  Simple
things may work, but confusing behavior will always be near.I'm not sure what 
these are, but they sound like what I would use in embedding the interpreter.  
But then again, this is a C function designed for embedding.  How could this be 
a problem?




Alan Baljeu




----- Original Message ----
From: Mike Driscoll <[EMAIL PROTECTED]>
To: python-list@python.org
Sent: Friday, November 14, 2008 12:08:06 PM
Subject: Re: automatic reload

On Nov 14, 11:04 am, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> I need a solution for automatically reloading files I edited.  This is in a 
> unit testing/fixing context, so there shouldn't be much problem with leftover 
> data.  I just need to be able to call a reload_changed() method of some sort 
> before rerunning tests.  Stopping and restarting the python interpreter (it's 
> embedded) might be an option if (a) that's feasible within a process and (b) 
> it's quick.
>
>  Alan Baljeuhttp://www.collaborative-systems.org
> Intelligent software that works _with_ you.
>

There's the "reload" builtin that you could use. In your method, just
call reload on the modules you need reloaded. TurboGears somehow
watches files for changes, so you might want to check out their source
to see how it works. I'm sure it's something similar.

Mike
--
http://mail.python.org/mailman/listinfo/python-list



      __________________________________________________________________
Get a sneak peak at messages with a handy reading pane with All new Yahoo! 
Mail: http://ca.promos.yahoo.com/newmail/overview2/



      __________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to