migrate the lock ownership from old_id to new_id
(self, key, old_id, new_id)
| 352 | self.save(roster) |
| 353 | |
| 354 | def migrate_lock(self, key, old_id, new_id): |
| 355 | """migrate the lock ownership from old_id to new_id""" |
| 356 | assert self.id == old_id |
| 357 | # need to switch off stale lock killing temporarily as we want to |
| 358 | # migrate rather than kill them (at least the one made by old_id). |
| 359 | killing, self.kill_stale_locks = self.kill_stale_locks, False |
| 360 | try: |
| 361 | try: |
| 362 | self.modify(key, REMOVE2) |
| 363 | except KeyError: |
| 364 | # entry was not there, so no need to add a new one, but still update our id |
| 365 | self.id = new_id |
| 366 | else: |
| 367 | # old entry removed, update our id and add a updated entry |
| 368 | self.id = new_id |
| 369 | self.modify(key, ADD) |
| 370 | finally: |
| 371 | self.kill_stale_locks = killing |
| 372 | |
| 373 | |
| 374 | class Lock: |