Skip to content

Commit

Permalink
merge 3.3-slp (Stackless python#120, fix grafting error)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anselm Kruis committed Apr 9, 2017
2 parents 7f5b617 + ae1d0a4 commit 5b2c817
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions Stackless/core/stacklesseval.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ void slp_kill_tasks_with_stacks(PyThreadState *target_ts)
*/
if (target_ts == NULL && tasklet_list) {
PyThreadState *ts;
PyObject *threadid_list = NULL;
count = 0;

/* build a list of tasklets to be killed */
Expand All @@ -640,30 +639,9 @@ void slp_kill_tasks_with_stacks(PyThreadState *target_ts)
}
SLP_HEAD_UNLOCK();

/* get the list of thread ids */
if (PyExc_TaskletExit)
threadid_list = slp_getthreads(Py_None); /* requires the HEAD lock */

/* kill the tasklets */
kill_pending(tasklet_list);
/* kill the threads */
if (threadid_list != NULL) {
Py_ssize_t i, len;
assert(PyList_CheckExact(threadid_list));
len = PyList_GET_SIZE(threadid_list);
for (i=0; i < len; i++) {
long thread_id;
PyObject *item = PyList_GET_ITEM(threadid_list, i);
assert(PyLong_CheckExact(item));
thread_id = PyLong_AsLong(item);
if (thread_id != cts->thread_id) {
/* requires the HEAD lock */
PyThreadState_SetAsyncExc(thread_id, PyExc_TaskletExit);
PyErr_Clear();
}
}
Py_DECREF(threadid_list);
}

/* We must not release the GIL while we might hold the HEAD-lock.
* Otherwise another thread (usually the thread of the killed tasklet)
* could try to get the HEAD lock. The result would be a wonderful dead lock.
Expand Down

0 comments on commit 5b2c817

Please sign in to comment.