[Stackless] slp_kill_tasks_with_stacks is broken
Kristján Valur Jónsson
kristjan at ccpgames.com
Fri Sep 23 11:52:21 CEST 2011
I've spent more thought on this.
The end_tasklet() game is played because we create many temporary main tasklets when we enter python through the C api.
This mechanism needs to be refined a bit when it comes to the main tasklet, for example, system exit exceptions should be propagated outwards on the main tasklet.
For the tstate cleanup, it appears that a new temporary main tasklet needs to be created for things to work.
I'll work some on getting these things shored up in the next days.
> -----Original Message-----
> From: stackless-bounces at stackless.com [mailto:stackless-
> bounces at stackless.com] On Behalf Of Richard Tew
> Sent: 23. september 2011 05:37
> To: The Stackless Python Mailing List
> Subject: Re: [Stackless] slp_kill_tasks_with_stacks is broken
> 2011/9/22 Kristján Valur Jónsson <kristjan at ccpgames.com>:
> > First, off, the code in tasklet_end, which clears the main tasklet, is
> > incompatible with the kill_task_with_cstate.
> > Secondly, the latter function does appear very fragile.
> No surprise, really. I expect that many of the things that contribute to this
> are bug fixes and improvements we have made when situations requiring
> them to do so have arisen.
> > What happens if a
> > tasklet that is being killed refuses to die?
> This is not our problem. How would it arise? A programmer ignoring a
> TaskletExit raised on a tasklet? It seems to me that in this situation we
> should detect it, and exit in such a way that it is up to the programmer to do
> the right thing if they don't want that to happen.
> > Or creates new tasklets?
> Shouldn't this be locked down for a thread when we reach the point where
> we are killing the tasklets for that thread? It seems like a straightforward
> > I
> > wonder if we should have a super exception, one that is not catchable
> > as a system_exit, to ensure that they die.. Or maybe just require
> > programs not to handle tasklet exit or do any magic tasklet stuff
> > during such a handle clause. But that's a different story.
> I do not think we need to make Stackless any more complicated. Anyone
> who is catching TaskletExit and not propagating it upwards is causing their
> own problems. Let's keep it simple.
> > What I think should happen is probably something like this. Assuming
> > that kill_tasks_with_cstate can be called with the man and current
> > tasklets still
> > valid:
> 0.5) Flag no more created tasklets on the give thread.
> > 1) All runnable tasklets are removed from the runnable queue and
> > decrefed, possibly resulting in them dying on their own or being
> > killed, leaving only the main tasklet in the queue.
> > 2) Then proceed with killing each tasklet. Now that there is
> > only one in the queue left, there is no need to worry about the queue
> Seems like a common sense fix to me.
> > Anyway, enough ranting. I'm not sure what to do here. It is annoying
> > that the main tasklet is cleared like this. But perhaps it is necessary.
> > Perhaps it is necessary to create a new temporary main tasklet. Who
> I had thought you had cleared it in a previous bug fix :p
> Stackless mailing list
> Stackless at stackless.com
More information about the Stackless