seatgeek/djjob — pull request #25 by jstayton (2013-04-03 22:22:10+00:00)
Title: Catch database connection timeout and retry query

Hey there,

First off, thanks for your work on DJJob! Very useful.

I've committed a change that wraps the PDO query executions in a try/catch block that retries the query if the database connection has timed out. It's MySQL-specific, but it doesn't interfere with other database types, and shouldn't be hard to extend to support those types as necessary.

The big question: Why? We've found that long-running jobs like transferring a multi-GB video file — which can take 10+ minutes — causes the DJJob database connection to timeout, preventing it from completing the necessary updates to the record. The connection timeout setting can always be increased, but I think this method is much more elegant and foolproof.

Let me know what you think. Thanks!