Django - Cronjobs Made Easy!

For those that have no interest in reading about my nerd-ventures, you can stop reading this post now.

If you're still reading, don't say I didn't warn you.

As has been mentioned previously (mainly on my previous blog), I've been doing a fair bit of side project work using the Django Framework. Sadly, the out-of-the-box Django doesn't provide a solution for running cronjobs (for tasks that need to be run within the Django environment).

Since that's a fairly common requirement I didn't think it was going to be a big deal, but there wasn't a really solid solution out there. There are a few different attempts, but they each have some limitation. There's django-cron but that just skips over the native cron entirely, which I felt was a bit extreme. Cron can already do a good job of waking up and running a command, so duplicating that functionality doesn't seem necessary. It also self-declares that it is designed for frequent tasks (hourly or more frequently), which doesn't work for me. Tasks on the Board need to be able to run from a minute scale to a daily scale and beyond.

Then I found this guy's method, which works, but I'd like a little more integration. That way when developing apps the "go add cron job" isn't a separate step. I want the job information to right in with the rest of my app information. That way I can see what should be happening and when.

That's when I came across Django-Chronograph. This solution was 95% of what I wanted. It provides a nice interface to the system to monitor your jobs and view logs. It requires only a single crontab entry. It uses the iCalendar style of task declaration so you have total control of when your jobs run. However, it is limited to running commands through the Django Management system. I wanted something a little more programmatic. Such that I could just point at whatever function I wanted for my jobs.

So I took Django-Chronograph and started my modifications. The result is Django Cron Manager. Setup is very similar to using the Admin system. You call the cron_manager.autodiscover() function from your urls.py file. This goes out and inspect your installed apps and registers any Cron Jobs they declare. Then, using the guts of Django-Chronograph, it keeps track of these jobs in the database and monitors when they need to run.

I'm planning on posting all the code with an example at some point, but I'm going to try to get in touch with Weston (the guy who wrote Django-Chronograph) to see if he just wants to roll my changes into his system permanently. If you stumble upon this post and the changes aren't in Django-Chronograph, and I haven't provided any further information. Just leave a comment that you're interested in the code with a way to contact you and I'll get something to you.

*** Update ***
I've posted the code here: http://code.google.com/p/django-chronograph/issues/detail?id=15

It's a start!

Okay, I've promised pictures of the apartment to some people. We've finally gotten mostly settled in, so here they are!

This is what you see when you walk in the front door:living room/from the front doorLike our couch? Yeah yeah...we're working on it. But the air mattress is filling in as a comfy way to watch TV. Just slightly to the right, we have this:

living roomWe're actually rather proud of those photo collages. We spent a long time on them, and if you hate them...well, please don't tell us. 😉 A bit further to the right of those pictures is a sliding door out onto our patio (I didn't take a picture because it's not very large or very pretty). And then you get back to the front door.

Continuing past the front door, we get the TV wall (so we're now opposite the air mattress):

living room...the dining area...

dining area...and the kitchen (which you may recognize from the popcorn fiasco). (The laundry room is through that door.)

kitchenThe hallway we skipped led to the spare bedroom, which we're using as an office...

office office office...and the other hallway leads to the master bedroom.

master bedroomSo there's actually a little bit more space in here than I managed to get in the picture, but it was difficult to get in, and I decided it wasn't worth it since there isn't a single bit of furniture in there other than the bed. Like the couch, a dresser and nightstands are on the list of things we've yet to purchase.

And, last but not least, the master bathroom:

master bathroomFor unknown reasons, this bathroom is smaller than the guest bathroom (that I didn't get a picture of).

And that concludes our tour.

It really did happen!

After weeks of waiting, it finally came!

So, I need an official, legal marriage certificate for all sorts of things, right? Like changing my name with Social Security and the DMV, for example. Well, I didn't have one. UNTIL NOW!!! Apparently, we filed with one of the lamest towns around, and they don't automatically send out this very important document. So after waiting for a couple of weeks, I called to see when it was going to arrive, only to be informed that I had to officially request one. And pay for it. Which meant I had to mail a request and a check.

Anyway, the certificate finally just arrived. Kyle kept asking what I would do if they responded with "Well, we don't actually have any record of that marriage taking place..." but that didn't happen, thankfully. Now I can get back to the really fun business of getting my name changed. Good times.

Shoulda knocked on wood...

Well, Mike, you were right. That last post was tempting fate, apparently, 'cuz about 6:30 on Monday night, the right side of my throat swelled up. A lot. We're talking golf-ball size. I, of course, stayed completely calm. Riiiiiiiight. I think it was more like this:

I was in the living room, watching TV, and Kyle was in the office, on his computer. I don't think my throat suddenly swelled up, but it suddenly became noticeable when it hurt to swallow the Cheez-Its I was munching on. "Kyle!" I yelled. "What?" "Something's...wrong!" And with that, I raced into the bathroom to examine my neck in the mirror. Yep; very swollen on the outside, and it was becoming difficult to swallow. Commence major loss of composure. It should be noted that Kyle's throat had been swollen for a day or two already, but I'd ordered him to keep it to himself, knowing full well that if I got a sore throat I'd freak. Apparently, the boy doesn't follow orders well.

Well, remembering the standing orders from both my surgeons, we proceeded to try and get some medical care. Our new HMO (Kaiser Permanente) is a little weird, but we've really liked it so far. So we called the appointment/advice line, hoping to get some info on an Urgent Care facility. Apparently, Kaiser doesn't do those, and this is lame. We were told that all the clinics were closed, so our only option was the ER. Also, the nurse was a jerk. I totally get that I sounded absolutely ridiculous, wanting to get in to see a doctor pronto for a swollen throat I'd had for 10 minutes with absolutely zero other symptoms. I really do. But I explained my situation to her and tried my very best to make her understand why this was serious; she just never got it, and she seemed very exasperated with me. Which, in the emotional state I was in, just hurt more. In any case, the ER seemed like overkill at that point, so we got an appointment for first thing Tuesday morning (my doctor wasn't available all that day, so with another doctor), and we just figured that if we really needed to, we could always go to the ER whenever we wanted to.

After that, I wanted a priesthood blessing, so Kyle called one of our home teachers, Barry, who came right over. He and Kyle gave me a blessing that really helped calm me down a lot. Tuesday morning, Kyle went with me to the dr.'s office (my appt. was at 9), but had to leave before the dr. actually came in (he had a meeting at 10, and she didn't come in until 10). I was glad he was able to sit with me, though, since it helped keep me from freaking out.

I had been concerned about explaining the severity of my situation to the dr., especially after my experience with the nurse on the phone, and since she was completely unfamiliar with my history. I needn't have worried, though: she was very nice and understanding and didn't act like I was some crazy person. (Perhaps it helped that she could see the huge, relatively fresh scars on my neck?) She said my right ear was a little swollen inside, so I probably just have a little bit of a cold, but she gave me some antibiotics just in case it's bacterial. (She acknowledged that ordinarily she wouldn't do that, but if it would help me feel better, she was fine with doing so.) And yes, I know there's a large chance the antibiotics won't have any effect at all. But as I know very well, it could be bacteria, and if it is, I'd just as soon get rid of it ASAP before it has a chance to develop any complications.

So I'm taking my antibiotics like a good girl. I don't think there's any change today, but at least it's not any worse, eh? And I'm not too worried, really. If I think about it too hard, I start fretting, but then something else pops into my head and I get distracted and quit worrying. So that's good. Hopefully, this will be better soon.

My evening alone

Tonight marks the first evening that Jess and I have spent away from each other. I must say it is strange. It is very quiet around here. For those that are just joining us here, Jess volunteered with the Utah County Rape Crisis Team when we lived in Utah. Eager to do similar volunteer work here in Livermore she found Tri-Valley Haven and joined up with their crisis team. Tonight was her first night of training, so that's where she's been all evening.

I decided that it would be a good evening to go for a run. I want to get back into running regularly, since I haven't been running since some time in February. So I took off jogging down Livermore Avenue. Boy am I out of shape. I jogged for about 1.5 miles before resting and stretching. Then I walked a mile and jogged the remaining half mile to get back home. It was a good run, I'm just completely out of shape.

The rest of the evening I've spent working on some programming projects. I did some work to keep the Board alive, and got the code base setup on my desktop so I can start working on Board 5 again. I made dinner (exciting plate of spaghetti and a slice of toast). And now I'm finishing up this blog post. Jess will be home in another 30 minutes or so. Maybe I'll play some Guitar Hero in the interim.

Also, unlike the cool weather Mike is having down in Sunnyvale, the weather here in Livermore is lovely:
Livermore_weatherThis is usually how the weather is, occasionally it gets cranky and pushes into the 90's and even the 100's, but that doesn't usually last very long. I certainly don't miss Utah summers.