Skip to content

Commit 948688f

Browse files
remove some tests
1 parent 48c58f8 commit 948688f

File tree

2 files changed

+12
-54
lines changed

2 files changed

+12
-54
lines changed

Lib/test/test_capi/test_misc.py

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,7 @@ def callback():
15601560
#try submitting callback until successful.
15611561
#rely on regular interrupt to flush queue if we are
15621562
#unsuccessful.
1563-
while True:
1564-
if _testcapi._pending_threadfunc(callback):
1565-
break
1563+
self.assertTrue(_testcapi._pending_threadfunc(callback))
15661564

15671565
def pendingcalls_submit(self, l, n, *, main=True):
15681566
def callback():
@@ -1633,51 +1631,11 @@ def test_main_pendingcalls_non_threaded(self):
16331631
#again, just using the main thread, likely they will all be dispatched at
16341632
#once. It is ok to ask for too many, because we loop until we find a slot.
16351633
#the loop can be interrupted to dispatch.
1636-
#there are only 32 dispatch slots, so we go for twice that!
16371634
l = []
16381635
n = 64
16391636
self.main_pendingcalls_submit(l, n)
16401637
self.pendingcalls_wait(l, n)
16411638

1642-
def test_max_pending(self):
1643-
with self.subTest('main-only'):
1644-
maxpending = 32
1645-
1646-
l = []
1647-
added = self.pendingcalls_submit(l, 1, main=True)
1648-
self.pendingcalls_wait(l, added)
1649-
self.assertEqual(added, 1)
1650-
1651-
l = []
1652-
added = self.pendingcalls_submit(l, maxpending, main=True)
1653-
self.pendingcalls_wait(l, added)
1654-
self.assertEqual(added, maxpending)
1655-
1656-
l = []
1657-
added = self.pendingcalls_submit(l, maxpending+1, main=True)
1658-
self.pendingcalls_wait(l, added)
1659-
self.assertEqual(added, maxpending)
1660-
1661-
with self.subTest('not main-only'):
1662-
# Per-interpreter pending calls has a much higher limit
1663-
# on how many may be pending at a time.
1664-
maxpending = 300
1665-
1666-
l = []
1667-
added = self.pendingcalls_submit(l, 1, main=False)
1668-
self.pendingcalls_wait(l, added)
1669-
self.assertEqual(added, 1)
1670-
1671-
l = []
1672-
added = self.pendingcalls_submit(l, maxpending, main=False)
1673-
self.pendingcalls_wait(l, added)
1674-
self.assertEqual(added, maxpending)
1675-
1676-
l = []
1677-
added = self.pendingcalls_submit(l, 1000, main=False)
1678-
self.pendingcalls_wait(l, added)
1679-
self.assertEqual(added, maxpending)
1680-
16811639
class PendingTask(types.SimpleNamespace):
16821640

16831641
_add_pending = _testinternalcapi.pending_threadfunc
@@ -1711,10 +1669,10 @@ def callback():
17111669
# the eval breaker, so we take a naive approach to
17121670
# make sure.
17131671
if threading.get_ident() not in worker_tids:
1714-
self._add_pending(callback, ensure_added=True)
1672+
self._add_pending(callback)
17151673
return
17161674
self.run()
1717-
self._add_pending(callback, ensure_added=True)
1675+
self._add_pending(callback)
17181676

17191677
def create_thread(self, worker_tids):
17201678
return threading.Thread(

Modules/_testinternalcapi.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,6 @@ pending_threadfunc(PyObject *self, PyObject *args, PyObject *kwargs)
10721072
PyObject *callable;
10731073
unsigned int num = 1;
10741074
int blocking = 0;
1075-
int ensure_added = 0;
10761075
static char *kwlist[] = {"callback", "num",
10771076
"blocking", NULL};
10781077
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
@@ -1096,6 +1095,7 @@ pending_threadfunc(PyObject *self, PyObject *args, PyObject *kwargs)
10961095
unsigned int num_added = 0;
10971096
for (; num_added < num; num_added++) {
10981097
if (_PyEval_AddPendingCall(interp, &_pending_callback, callable, 0) < 0) {
1098+
// out of memory and freelist is empty
10991099
break;
11001100
}
11011101
}
@@ -1152,14 +1152,14 @@ pending_identify(PyObject *self, PyObject *args)
11521152
PyThread_acquire_lock(mutex, WAIT_LOCK);
11531153
/* It gets released in _pending_identify_callback(). */
11541154

1155-
int r;
1156-
do {
1157-
Py_BEGIN_ALLOW_THREADS
1158-
r = _PyEval_AddPendingCall(interp,
1159-
&_pending_identify_callback, (void *)mutex,
1160-
0);
1161-
Py_END_ALLOW_THREADS
1162-
} while (r < 0);
1155+
1156+
Py_BEGIN_ALLOW_THREADS
1157+
int r = _PyEval_AddPendingCall(interp,
1158+
&_pending_identify_callback, (void *)mutex,
1159+
0);
1160+
(void)r;
1161+
assert(r == 0);
1162+
Py_END_ALLOW_THREADS
11631163

11641164
/* Wait for the pending call to complete. */
11651165
PyThread_acquire_lock(mutex, WAIT_LOCK);

0 commit comments

Comments
 (0)