The cake is a lie

Gentoo, Rockband, Code, and Music

Today, you’ll get to hear about what I’ve been up to! This wont be on the exam.

  • After a year and a half stint with Ubuntu, I’m back to my true love Gentoo. That is, with a shiny matte new quad core beast of a machine.
  • Bought Rockband for my PS3 couple of weeks ago. Drums are ridiculously hard. Been rocking out. Good fun is being had by all those who dare rock. Can’t wait for Still Alive to be released for free. It shall be a triumph!
  • What started out as pretty code is now a bonafide open source Python module: workerpool. People are using it. No, really.
  • muxtape.com: A super simple music sharing web app launched last week. Its been enriching my life — doing what Pandora once did. Here’s my muxtape. Be right back, there’s someone at the door.
5 comments

Code storytelling

It’s fun writing code that tells a story. Hopefully it’s also fun reading it.


class TerminationNotice(Exception):
    "Exception raised inside a thread when it's time for it to die."
    pass
 
class SuicideJob(QueryJob):
    "A worker receiving this job will commit suicide."
    def run(self):
        raise TerminationNotice()
 
class QueryWorker(Thread):
    "Devoted worker who will pull jobs from the `jobs` queue and perform them."
    def __init__(self, jobs):
        self.jobs = jobs
        Thread.__init__(self)
 
    def run(self):
        "Get jobs from the queue and perform them."
        while 1:
            job = self.jobs.get()
            if not isinstance(job, QueryJob):
                debug.error("%r ate a job that wasn't a edible: %r" % (self, job))
                continue
            try:
                job.run()
            except TerminationNotice:
                # Nice knowing you :(
                break
No comments