Monthly Archives: November 2009

I’ve been playing around with Tornado a bit and wanted to asynchronously call a long-running shell command without blocking the server process. Here is my solution.

Running this server I am able to visit http://localhost:8888/test/ numerous times while a request for http://localhost:8888/ is waiting for the command to finish. The beauty of this is that this is a single process with a single thread. With a process this light and fast, a relatively large number of applications can be crammed into a $10/mo hosted account.

#!/usr/bin/env python
import os
import tornado.httpserver
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    @tornado.web.asynchronous
    def get(self):
        self.ioloop = tornado.ioloop.IOLoop.instance()
        self.pipe = p = os.popen('sleep 5; cat /etc/mime.types')
        self.ioloop.add_handler( p.fileno(), self.async_callback(self.on_response), self.ioloop.READ )

    def on_response(self,fd,events):
        for line in self.pipe:
            self.write( line )

        self.ioloop.remove_handler(fd)
        self.finish()

class TestHandler(tornado.web.RequestHandler):
    def get(self):
        self.write('this is a test')

application = tornado.web.Application([
    (r"/", MainHandler),
    (r"/test/", TestHandler),
])

if __name__ == "__main__":
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

If you haven’t heard about the ClimateGate scandal, then you’ve been hiding under a rock.

Late last week hackers penetrated systems at the Climate Research Unit (CRU) at the University of East Anglia in the UK. The CRU is considered something of a global hub for climate-change “science.” What the released email revealed is that climate scientists have been deliberately deceptive and scientifically disingenuous in their campaign to stop “climate change.” Contrary data has been concealed or even tampered with to hide evidence contrary to climate change theories.

Science in the strictest sense is the objective application of the scientific method (i.e. observation, hypothesis, testing, lather-rinse-repeat). A scientist is someone who is understood to objectively follow the scientific method. But for the average lay person science is “whatever scientists say.” The average lay person doesn’t understand the advanced mathematics behind the climate models and thus can never really understand the “science.” He has to trust the scientist to tell him what he knows. That is “science.”

In today’s world “science” is held in very high regard. Few dare to question the teachings of “science.” “Science” has produced space travel, the internet, modern health-care, and other wonders too numerous to mention. But what people haven’t realized en masse is that “science” is really a matter of faith… in scientists.

Even though we can see the evidence of many scientific successes, entire fields of “science” do not produce tangible results. The present case of climate change “science” in particular is a purely speculative theory with no possibility of proof (and consequently it does not follow the scientific method). Similar examples are string theory, Darwinian evolution, and big bang theory.

While on the one hand we are given many tangible wonders like iPhones and cars to dazzle the mind and lend “science” credibility, on the other hand we are fed unproven theories as factual doctrine.  While the wizards of science put on a wondrous show for us with all the whiz-bang gadgets, when we pull back the curtain we see only a fraud.

There is no wizard.

There is no scientist.

sheepologyThings have changed a bit since I last created a structure diagram for Sheepology. This graph was generated by django-command-extensions and Graphviz.

Version control seems to be broken in the demo right now. It’s probably due to all the version changes of Django and such that have happened since last I test this feature.

UPDATE: Versioning is fixed. I had to install django-reversion 1.2 so it would work with Django 1.1.1.

I just rolled out an update to the Sheepology demo. Many changes have taken place since this demo was last updated:

  • Content management system – I needed this ASAP so it was what I’ve worked on for the last month or so.  It doesn’t have a lot of features right now, but has an architecture that I am very happy with and is highly extensible.
  • Revamped the communications architecture.
  • Generalized the Flex-based visual tree editor so that it could be used with more than just groups. It is now being used for content categories as well. (I would actually like to rewrite this in Javascript now that I have played with raphael.js)
  • Added version control for pretty much anything of importance (people, groups, events, content, etc.) using django-reversion. You can easily restore deleted people, content, whatever, or revert to previous versions.
  • Updated the theme to the latest version of Grappelli
  • Optimized some queries
  • Got the whole thing running under Tornado instead of Apache. It now uses much less memory and runs in a single process. In theory it should be very fast but I haven’t load tested it yet.

I hope to role this out into production in my church (the “public” site in the demo is a previews of the site I’m doing for my church).

The list of features I want to add is growing faster than the list of items completed, but I think I need to get something into production and get it field tested before going too much further.