@@ -3958,6 +3958,42 @@ def test_semaphore_tracker(self):
39583958 self .assertRegex (err , expected )
39593959 self .assertRegex (err , r'semaphore_tracker: %r: \[Errno' % name1 )
39603960
3961+ class TestSimpleQueue (unittest .TestCase ):
3962+
3963+ @classmethod
3964+ def _test_empty (cls , queue , child_can_start , parent_can_continue ):
3965+ child_can_start .wait ()
3966+ # issue 30301, could fail under spawn and forkserver
3967+ try :
3968+ queue .put (queue .empty ())
3969+ queue .put (queue .empty ())
3970+ finally :
3971+ parent_can_continue .set ()
3972+
3973+ def test_empty (self ):
3974+ queue = multiprocessing .SimpleQueue ()
3975+ child_can_start = multiprocessing .Event ()
3976+ parent_can_continue = multiprocessing .Event ()
3977+
3978+ proc = multiprocessing .Process (
3979+ target = self ._test_empty ,
3980+ args = (queue , child_can_start , parent_can_continue )
3981+ )
3982+ proc .daemon = True
3983+ proc .start ()
3984+
3985+ self .assertTrue (queue .empty ())
3986+
3987+ child_can_start .set ()
3988+ parent_can_continue .wait ()
3989+
3990+ self .assertFalse (queue .empty ())
3991+ self .assertEqual (queue .get (), True )
3992+ self .assertEqual (queue .get (), False )
3993+ self .assertTrue (queue .empty ())
3994+
3995+ proc .join ()
3996+
39613997#
39623998# Mixins
39633999#
0 commit comments