Skip to content

Commit 11897fc

Browse files
committed
Merge branch 'pythongh-110481-brc-bind' into nogil-integration
2 parents 1dad954 + e697b37 commit 11897fc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Python/brc.c

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ _Py_brc_merge_refcounts(PyThreadState *tstate)
119119
struct _brc_thread_state *brc = &((_PyThreadStateImpl *)tstate)->brc;
120120
struct _brc_bucket *bucket = get_bucket(tstate->interp, brc->tid);
121121

122+
assert(brc->tid == _Py_ThreadId());
123+
122124
// Append all objects into a local stack. We don't want to hold the lock
123125
// while calling destructors.
124126
PyMutex_Lock(&bucket->mutex);

Python/pystate.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ bind_tstate(PyThreadState *tstate)
261261
tstate->native_thread_id = PyThread_get_thread_native_id();
262262
#endif
263263

264+
#ifdef Py_GIL_DISABLED
265+
// Initialize biased reference counting inter-thread queue. Note that this
266+
// needs to be initialized from the active thread.
267+
_Py_brc_init_thread(tstate);
268+
#endif
269+
264270
// mimalloc state needs to be initialized from the active thread.
265271
tstate_mimalloc_bind(tstate);
266272

@@ -1424,10 +1430,6 @@ init_threadstate(_PyThreadStateImpl *_tstate,
14241430
tstate->what_event = -1;
14251431
tstate->previous_executor = NULL;
14261432

1427-
#ifdef Py_GIL_DISABLED
1428-
// Initialize biased reference counting inter-thread queue
1429-
_Py_brc_init_thread(tstate);
1430-
#endif
14311433
llist_init(&_tstate->mem_free_queue);
14321434

14331435
if (interp->stoptheworld.requested || _PyRuntime.stoptheworld.requested) {

0 commit comments

Comments
 (0)