durusmail: qp: Subclassing Site thoughts.
Subclassing Site thoughts.
2006-06-27
2006-06-27
2006-06-27
2006-06-27
2006-06-27
2006-06-27
2006-06-28
2006-06-28
2006-06-27
2006-06-27
2006-06-28
Subclassing Site thoughts.
Peter Wilkinson
2006-06-27
Hi,
I've been progressing on prototype work with QP and continue to be
very impressed with what can be done with very little code and the
really stunning performance that comes from QP/Durus combination.

After my last email about some help with site architecture I've been
building in some of the ideas based on the responses to that, thanks
all, and while having no problems getting all I need going I'm
finding myself doing a bunch of copy and paste to subclass Site and
replace a couple of the methods.

The two big pieces that we are changing for some of our sites are the
web server portion and the storage engine that Durus uses. We've put
together an async web server based on code from the ASPN cookbook
(mainly for memory usage) and for Durus I've put together a storage
engine based on SQLite that helps with startup time and memory usage
when managing a large number of objects.

The issue with doing this is that start_web and start_durus aren't
fine grained enough to do the subclassing cleanly. Making a
Site.run_web and Site.run_durus that replaced the code between the
try: finally: section of both of those methods would be ideal. Any
possibility of getting something like that?

Another Durus issue is getting unix domain sockets working which
requires a few changes from the host, port model. If this is not
changed internally for a future release I'm more than happy to supply
a patch.

Another useful piece we've added is a development time reloader
process that will watch *.py and *.qpy is nominated directories and
restart QP if any changes are seen. This works very well in practice
for development. If anyone would like to have a look, let me know and
I'll send through the code. One small change that would be nice given
this kind of reload is in stop_web, changing lines from 399 to:
                 kill(pid, signal.SIGTERM)
                 if self.is_web_running():
                     sleep(1)
would be nice as the first sleep isn't often needed when running on a
lightly loaded development machine, the process just dies immediately.

Regards,
Peter Wilkinson

reply