[Stackless] how does my tasklets and objects get freed
Kristján Valur Jónsson
kristjan at ccpgames.com
Thu Jan 28 15:11:37 CET 2010
If there is no reference to the tasklet, how do you expect to restart it?
Looking at your code, obviously the call to event_set(), if it is to store the tasklet for later wakeup,
must do a Py_INCREF() on it. Anyone intending to store a reference must Incref.
K
> -----Original Message-----
> From: stackless-bounces at stackless.com [mailto:stackless-
> bounces at stackless.com] On Behalf Of Péter Szabó
> Sent: 28. janúar 2010 11:26
> To: The Stackless Python Mailing List
> Subject: [Stackless] how does my tasklets and objects get freed
>
> Hi,
>
> I'm using Stackless 2.6 with some Pyrex (C) code, and I'd like to make
> sure that my objects won't be free()d too early (by reference counting
> or garbage collection).
>
> I have a C function like this:
>
> void MyFunction() {
> struct event_t ev;
> PyTaskletObject *tasklet;
> ...
> tasklet = PyStackless_GetCurrent();
> event_set(&ev, ..., ..., ..., (void*)tasklet);
> event_add(&ev, NULL)
> PyStackless_Schedule(None, 1); /* stackless.schdule_remove() */
> ...
> Py_DECREF(tasklet);
> }
>
> I'm afraid that after the call to PyStackless_Schedule, it may happen
> that there will be no reference to this tasklet, so the garbage
> collector might free() it at some point. I want to prevent this from
> happening, the tasklet must be kept until it gets scheduled again, and
> Py_DECREF(tasklet) is run. How do I ensure this?
>
> Thanks,
>
> Péter
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
More information about the Stackless
mailing list