[Twisted-Python] WSGI Question

Landreville landreville at deadtreepages.com
Wed Jan 20 10:40:34 EST 2010

On Wed, Jan 20, 2010 at 9:58 AM, adamjamesdrew same <theiklabs at gmail.com> wrote:
> I deploy code. Then I modify the code on my file system. The code does not
> automatically change on the server. It does this on the django dev server.
> How can I make this happen?
> I start the server as follows
> twistd -ny server.py
> # Django and static file server:
> root_resource = get_root_resource()
> root_resource.putChild("static", static.File("static"))
> http_factory = server.Site(root_resource, logPath="http.log")
> internet.TCPServer(STATIC_PORT, http_factory,
> interface=INTERFACE).setServiceParent(serviceCollection)

The twisted modules are only loaded once because it asynchronous, so
the twisted server is persistent in memory. You only load your twisted
app once, whereas in django the modules are reloaded on every page
refresh on the dev server.

There are some nifty live reloading things you can do. One of them is
to just reload the module (i think its a builtin method called reload)
but only new objects will use the reloaded module. There is a module
in twisted.python somewhere that does some live reloading magic to try
and replace all the references with the newly loaded module.

It's actually fairly complicated and if your in a development
environment it is probably easier to reload twisted than add all the
reloading stuff to your classes. I haven't used the twisted reloading
stuff though. In my case I tore down some of the objects that were
created with the classes in the module, reloaded the associated
modules, then rebuilt those objects. And if you're doing that to your
whole project, it would be about the same as just restarting the

Someone from the twisted project can probably give you better
information about reloading changes.

More information about the Twisted-Python mailing list