@@ -1492,6 +1492,25 @@ def test_lock(self):
14921492 self .assertFalse (lock .locked ())
14931493 self .assertRaises ((ValueError , threading .ThreadError ), lock .release )
14941494
1495+ @classmethod
1496+ def _test_lock_locked_2processes (cls , lock , event ):
1497+ lock .acquire ()
1498+ event .set ()
1499+
1500+ def test_lock_locked_2processes (self ):
1501+ if self .TYPE != 'processes' :
1502+ self .skipTest ('test not appropriate for {}' .format (self .TYPE ))
1503+
1504+ lock = self .Lock ()
1505+ event = self .Event ()
1506+ p = self .Process (target = self ._test_lock_locked_2processes ,
1507+ args = (lock , event ))
1508+ p .start ()
1509+ event .wait ()
1510+ self .assertTrue (lock .locked ())
1511+ p .join ()
1512+ print (lock , event )
1513+
14951514 @staticmethod
14961515 def _acquire_release (lock , timeout , l = None , n = 1 ):
14971516 for _ in range (n ):
@@ -1561,6 +1580,20 @@ def test_rlock(self):
15611580 self .assertFalse (lock .locked ())
15621581 self .assertRaises ((AssertionError , RuntimeError ), lock .release )
15631582
1583+ def test_rlock_locked_2processes (self ):
1584+ if self .TYPE != 'processes' :
1585+ self .skipTest ('test not appropriate for {}' .format (self .TYPE ))
1586+
1587+ rlock = self .RLock ()
1588+ event = self .Event ()
1589+ # target is the same as for the test_lock_locked_2processes test.
1590+ p = self .Process (target = self ._test_lock_locked_2processes ,
1591+ args = (rlock , event ))
1592+ p .start ()
1593+ event .wait ()
1594+ self .assertTrue (rlock .locked ())
1595+ p .join ()
1596+
15641597 def test_lock_context (self ):
15651598 with self .Lock () as locked :
15661599 self .assertTrue (locked )
0 commit comments