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
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to