By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

Fw: automatic reload

P: n/a


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

----- Forwarded Message ----
From: Alan Baljeu <al********@yahoo.com>
To: Mike Driscoll <ky******@gmail.com>
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 <ky******@gmail.com>
To: py*********@python.org
Sent: Friday, November 14, 2008 12:08:06 PM
Subject: Re: automatic reload

On Nov 14, 11:04 am, Alan Baljeu <alanbal...@yahoo.comwrote:
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/
Nov 14 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.