File tree 8 files changed +127
-82
lines changed
Misc/NEWS.d/next/Core and Builtins 8 files changed +127
-82
lines changed Original file line number Diff line number Diff line change @@ -1389,6 +1389,10 @@ pointer and a void pointer argument.
1389
1389
This function doesn't need a current thread state to run, and it doesn't
1390
1390
need the global interpreter lock.
1391
1391
1392
+ To call this function in a subinterpreter, the caller must hold the GIL.
1393
+ Otherwise, the function *func* can be scheduled to be called from the wrong
1394
+ interpreter.
1395
+
1392
1396
.. warning::
1393
1397
This is a low-level function, only useful for very special cases.
1394
1398
There is no guarantee that *func* will be called as quick as
@@ -1397,6 +1401,12 @@ pointer and a void pointer argument.
1397
1401
function is generally **not** suitable for calling Python code from
1398
1402
arbitrary C threads. Instead, use the :ref:`PyGILState API<gilstate>`.
1399
1403
1404
+ .. versionchanged:: 3.9
1405
+ If this function is called in a subinterpreter, the function *func* is
1406
+ now scheduled to be called from the subinterpreter, rather than being
1407
+ called from the main interpreter. Each subinterpreter now has its own
1408
+ list of scheduled calls.
1409
+
1400
1410
.. versionadded:: 3.1
1401
1411
1402
1412
.. _profiling:
Original file line number Diff line number Diff line change @@ -514,6 +514,12 @@ Build and C API Changes
514
514
515
515
Extension modules without module state (``m_size <= 0 ``) are not affected.
516
516
517
+ * If :c:func: `Py_AddPendingCall ` is called in a subinterpreter, the function is
518
+ now scheduled to be called from the subinterpreter, rather than being called
519
+ from the main interpreter. Each subinterpreter now has its own list of
520
+ scheduled calls.
521
+ (Contributed by Victor Stinner in :issue: `39984 `.)
522
+
517
523
518
524
Deprecated
519
525
==========
Original file line number Diff line number Diff line change @@ -35,12 +35,8 @@ struct _pending_calls {
35
35
36
36
struct _ceval_runtime_state {
37
37
int recursion_limit ;
38
- /* This single variable consolidates all requests to break out of
39
- the fast path in the eval loop. */
40
- _Py_atomic_int eval_breaker ;
41
38
/* Request for dropping the GIL */
42
39
_Py_atomic_int gil_drop_request ;
43
- struct _pending_calls pending ;
44
40
/* Request for checking signals. */
45
41
_Py_atomic_int signals_pending ;
46
42
struct _gil_runtime_state gil ;
@@ -53,6 +49,10 @@ struct _ceval_state {
53
49
c_tracefunc. This speeds up the if statement in
54
50
_PyEval_EvalFrameDefault() after fast_next_opcode. */
55
51
int tracing_possible ;
52
+ /* This single variable consolidates all requests to break out of
53
+ the fast path in the eval loop. */
54
+ _Py_atomic_int eval_breaker ;
55
+ struct _pending_calls pending ;
56
56
};
57
57
58
58
/* interpreter state */
Original file line number Diff line number Diff line change
1
+ If :c:func: `Py_AddPendingCall ` is called in a subinterpreter, the function is
2
+ now scheduled to be called from the subinterpreter, rather than being called
3
+ from the main interpreter. Each subinterpreter now has its own list of
4
+ scheduled calls.
Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ trip_signal(int sig_num)
304
304
if (wakeup .warn_on_full_buffer ||
305
305
last_error != WSAEWOULDBLOCK )
306
306
{
307
- /* Py_AddPendingCall () isn't signal-safe, but we
307
+ /* _PyEval_AddPendingCall () isn't signal-safe, but we
308
308
still use it for this exceptional case. */
309
309
_PyEval_AddPendingCall (tstate ,
310
310
report_wakeup_send_error ,
@@ -323,7 +323,7 @@ trip_signal(int sig_num)
323
323
if (wakeup .warn_on_full_buffer ||
324
324
(errno != EWOULDBLOCK && errno != EAGAIN ))
325
325
{
326
- /* Py_AddPendingCall () isn't signal-safe, but we
326
+ /* _PyEval_AddPendingCall () isn't signal-safe, but we
327
327
still use it for this exceptional case. */
328
328
_PyEval_AddPendingCall (tstate ,
329
329
report_wakeup_write_error ,
You can’t perform that action at this time.
0 commit comments