Skip to content

Commit

Permalink
Don't try to kill main greenlets
Browse files Browse the repository at this point in the history
Main greenlets can only be deallocated when their
thread is gone, so trying to kill it will only
cause a leak. Only checking for run_info is not
enough, because deallocation path might not have
involved tp_clear.
  • Loading branch information
snaury committed May 13, 2012
1 parent 34621db commit dae2314
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion greenlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static void green_dealloc(PyGreenlet* self)
PyObject_GC_UnTrack((PyObject *)self);
Py_TRASHCAN_SAFE_BEGIN(self);
#endif /* GREENLET_USE_GC */
if (PyGreenlet_ACTIVE(self) && self->run_info != NULL) {
if (PyGreenlet_ACTIVE(self) && self->run_info != NULL && !PyGreenlet_MAIN(self)) {
/* Hacks hacks hacks copied from instance_dealloc() */
/* Temporarily resurrect the greenlet. */
assert(Py_REFCNT(self) == 0);
Expand Down

0 comments on commit dae2314

Please sign in to comment.