'Utility method that runs a SELECT FOR UPDATE against all
Person instances. After the select_for_update, it attempts
to update the name of the only record, save, and commit.
This function expects to run in a separate thread.'

def run_select_for_update(self, status, nowait=False):

    status.append('started')
    try:
        transaction.enter_transaction_management()
        people = list(Person.objects.all().select_for_update(nowait=nowait))
        people[0].name = 'Fred'
        people[0].save()
        transaction.commit()
    except DatabaseError as e:
        status.append(e)
    finally:
        transaction.abort()
        connection.close()
