Tmp

rename _get_locks to __get_locks. Write _get_locks, that'll decorate __get_locks as a whole (as it is now). Try to change 'count' so that it is always only 0 or 1 (unless you do multiple simultaneous updates to the DB).

Ask marcelka, if anything is unclear.