Kaydet (Commit) 0f1f63cf authored tarafından Guido van Rossum's avatar Guido van Rossum

Close the discussion in SF bug 1069160.

üst 7fcb7869
...@@ -320,7 +320,7 @@ PyThreadState_GetDict(void) ...@@ -320,7 +320,7 @@ PyThreadState_GetDict(void)
/* Asynchronously raise an exception in a thread. /* Asynchronously raise an exception in a thread.
Requested by Just van Rossum and Alex Martelli. Requested by Just van Rossum and Alex Martelli.
To prevent naive misuse, you must write your own exception To prevent naive misuse, you must write your own extension
to call this. Must be called with the GIL held. to call this. Must be called with the GIL held.
Returns the number of tstates modified; if it returns a number Returns the number of tstates modified; if it returns a number
greater than one, you're in trouble, and you should call it again greater than one, you're in trouble, and you should call it again
...@@ -332,6 +332,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) { ...@@ -332,6 +332,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) {
PyInterpreterState *interp = tstate->interp; PyInterpreterState *interp = tstate->interp;
PyThreadState *p; PyThreadState *p;
int count = 0; int count = 0;
HEAD_LOCK();
for (p = interp->tstate_head; p != NULL; p = p->next) { for (p = interp->tstate_head; p != NULL; p = p->next) {
if (p->thread_id != id) if (p->thread_id != id)
continue; continue;
...@@ -340,6 +341,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) { ...@@ -340,6 +341,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) {
p->async_exc = exc; p->async_exc = exc;
count += 1; count += 1;
} }
HEAD_UNLOCK();
return count; return count;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment