Sunday, April 8, 2012

Re: Reloading a project without restarting Python

On Sat, Apr 7, 2012 at 2:32 PM, Tobia Conforto
<tobia.conforto@gruppo4.eu> wrote:
> Hi all
>
> I'm developing a portlet bridge in Jython, to enable developing J2EE
> portlets in Django, and I need to include a reload-on-code-change
> feature, to aid in development.
>
> Unfortunately, the way django.utils.autoreload works, by triggering a
> complete restart of the Jython interpreter, has huge memory and thread
> leaks in Jython.  It would appear that there is no clean way to unload
> a
> Jython interpreter from the JVM once it's been started.  (For backing
> of
> this assertion, see my latest post on the jython-users list.)
>
> Therefore I'd like to know if there is a way to reload a Django
> project
> from within Python, without restarting the interpreter itself.
>
> For normal development it would be enough to reload the project's own
> models, views, urls, admin, form, middleware and such classes.  Some
> of
> the settings could be kept, if it made the reloading simpler, such as
> filesystem paths, database connections, installed apps and middleware.
>
> Any changes to the standard library, Django, and in general any code
> that is not part of the current project's module could be ignored. If
> a developer needs to reload that, he can very well restart everything!
>
> Does anybody have any advice on how to do this?

I don't believe that this is possible. While you can apply the reload()
built in function to a module, other modules which have references to,
for example, class objects (an instance has a reference __class__ to
its class object), will still be referring to the old instance. Finding all
references and fixing them is a hard, if not impossible, problem.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate