@@ -1557,27 +1557,20 @@ def callback():
15571557
15581558 for i in range (n ):
15591559 time .sleep (random .random ()* 0.02 ) #0.01 secs on average
1560- #try submitting callback until successful.
1561- #rely on regular interrupt to flush queue if we are
1562- #unsuccessful.
1563- while True :
1564- if _testcapi ._pending_threadfunc (callback ):
1565- break
1560+ self .assertTrue (_testcapi ._pending_threadfunc (callback ))
15661561
1567- def pendingcalls_submit (self , l , n , * , main = True , ensure = False ):
1562+ def pendingcalls_submit (self , l , n , * , main = True ):
15681563 def callback ():
15691564 #this function can be interrupted by thread switching so let's
15701565 #use an atomic operation
15711566 l .append (None )
15721567
15731568 if main :
15741569 return _testcapi ._pending_threadfunc (callback , n ,
1575- blocking = False ,
1576- ensure_added = ensure )
1570+ blocking = False )
15771571 else :
15781572 return _testinternalcapi .pending_threadfunc (callback , n ,
1579- blocking = False ,
1580- ensure_added = ensure )
1573+ blocking = False )
15811574
15821575 def pendingcalls_wait (self , l , numadded , context = None ):
15831576 #now, stick around until l[0] has grown to 10
@@ -1635,51 +1628,11 @@ def test_main_pendingcalls_non_threaded(self):
16351628 #again, just using the main thread, likely they will all be dispatched at
16361629 #once. It is ok to ask for too many, because we loop until we find a slot.
16371630 #the loop can be interrupted to dispatch.
1638- #there are only 32 dispatch slots, so we go for twice that!
16391631 l = []
16401632 n = 64
16411633 self .main_pendingcalls_submit (l , n )
16421634 self .pendingcalls_wait (l , n )
16431635
1644- def test_max_pending (self ):
1645- with self .subTest ('main-only' ):
1646- maxpending = 32
1647-
1648- l = []
1649- added = self .pendingcalls_submit (l , 1 , main = True )
1650- self .pendingcalls_wait (l , added )
1651- self .assertEqual (added , 1 )
1652-
1653- l = []
1654- added = self .pendingcalls_submit (l , maxpending , main = True )
1655- self .pendingcalls_wait (l , added )
1656- self .assertEqual (added , maxpending )
1657-
1658- l = []
1659- added = self .pendingcalls_submit (l , maxpending + 1 , main = True )
1660- self .pendingcalls_wait (l , added )
1661- self .assertEqual (added , maxpending )
1662-
1663- with self .subTest ('not main-only' ):
1664- # Per-interpreter pending calls has a much higher limit
1665- # on how many may be pending at a time.
1666- maxpending = 300
1667-
1668- l = []
1669- added = self .pendingcalls_submit (l , 1 , main = False )
1670- self .pendingcalls_wait (l , added )
1671- self .assertEqual (added , 1 )
1672-
1673- l = []
1674- added = self .pendingcalls_submit (l , maxpending , main = False )
1675- self .pendingcalls_wait (l , added )
1676- self .assertEqual (added , maxpending )
1677-
1678- l = []
1679- added = self .pendingcalls_submit (l , maxpending + 1 , main = False )
1680- self .pendingcalls_wait (l , added )
1681- self .assertEqual (added , maxpending )
1682-
16831636 class PendingTask (types .SimpleNamespace ):
16841637
16851638 _add_pending = _testinternalcapi .pending_threadfunc
@@ -1713,10 +1666,10 @@ def callback():
17131666 # the eval breaker, so we take a naive approach to
17141667 # make sure.
17151668 if threading .get_ident () not in worker_tids :
1716- self ._add_pending (callback , ensure_added = True )
1669+ self ._add_pending (callback )
17171670 return
17181671 self .run ()
1719- self ._add_pending (callback , ensure_added = True )
1672+ self ._add_pending (callback )
17201673
17211674 def create_thread (self , worker_tids ):
17221675 return threading .Thread (
0 commit comments