## Revision 73c25d35 test/ganeti.locking_unittest.py

b/test/ganeti.locking_unittest.py
1503 1503
```        tlock.release()
```
1504 1504

1505 1505
```    # Test shared acquire
```
1506
```    def _Acquire(lock, shared, ev):
```
1506
```    def _Acquire(lock, shared, ev, notify):
```
1507 1507
```      lock.acquire(shared=shared)
```
1508 1508
```      try:
```
1509
```        notify.set()
```
1509 1510
```        ev.wait()
```
1510 1511
```      finally:
```
1511 1512
```        lock.release()
```
......
1513 1514
```    for tlock1 in locks[::11]:
```
1514 1515
```      for tlock2 in locks[::-15]:
```
1515 1516
```        if tlock2 == tlock1:
```
1517
```          # Avoid deadlocks
```
1516 1518
```          continue
```
1517 1519

1518 1520
```        for tlock3 in locks[::10]:
```
1519
```          if tlock3 == tlock2:
```
1521
```          if tlock3 in (tlock2, tlock1):
```
1522
```            # Avoid deadlocks
```
1520 1523
```            continue
```
1521 1524

1522
```          ev = threading.Event()
```
1525
```          releaseev = threading.Event()
```
1523 1526

1524 1527
```          # Acquire locks
```
1528
```          acquireev = []
```
1525 1529
```          tthreads1 = []
```
1526 1530
```          for i in range(3):
```
1531
```            ev = threading.Event()
```
1527 1532
```            tthreads1.append(self._addThread(target=_Acquire,
```
1528
```                                             args=(tlock1, 1, ev)))
```
1529
```          tthread2 = self._addThread(target=_Acquire, args=(tlock2, 1, ev))
```
1530
```          tthread3 = self._addThread(target=_Acquire, args=(tlock3, 0, ev))
```
1533
```                                             args=(tlock1, 1, releaseev, ev)))
```
1534
```            acquireev.append(ev)
```
1535

1536
```          ev = threading.Event()
```
1537
```          tthread2 = self._addThread(target=_Acquire,
```
1538
```                                     args=(tlock2, 1, releaseev, ev))
```
1539
```          acquireev.append(ev)
```
1540

1541
```          ev = threading.Event()
```
1542
```          tthread3 = self._addThread(target=_Acquire,
```
1543
```                                     args=(tlock3, 0, releaseev, ev))
```
1544
```          acquireev.append(ev)
```
1545

1546
```          # Wait for all locks to be acquired
```
1547
```          for i in acquireev:
```
1548
```            i.wait()
```
1531 1549

1532 1550
```          # Check query result
```
1533 1551
```          for (name, mode, owner) in self.lm.QueryLocks(["name", "mode",
```
......
1552 1570
```            self.assert_(owner is None)
```
1553 1571

1554 1572
```          # Release locks again
```
1555
```          ev.set()
```
1573
```          releaseev.set()
```
1556 1574

1557 1575
```          self._waitThreads()
```
1558 1576

Also available in: Unified diff