Rollback, don't commit left over transactions

Celery keeps the state of global objects inside of the same worker from
one execution of a task to the next.  In this case, that mean db.session
objects are carried over, including their transaction state.

If there is a transaction left over from a previous task, it is better
to roll it back than to commit it.  This should also help with
db.session objects that are caught in an invalid transaction state,
because those not an explicit rollback to start a new transaction.
Rework delete_task celery task to be more robust

Checking whether the job this task belonged to should be deleted as well
is now done in a separate, new transaction.  This means that, at that
point, we also get to see changes that other transactions have made in
the time since our first one started.  This should help with some
concurrency issues that used to plague job deletions.

Failed transactions are now explicitly rolled back and retried up to ten
times.
Import InvalidRequestError to pacify pylint
Make transaction retries configurable
Use %r in logstring:wq:
Merge pull request #288 from guidow/more_robust_task_deletion

More robust task deletion