[Stackless] Issue #28: enhance tasklet.bind() (stackless-dev/stackless)

Anselm Kruis issues-reply at bitbucket.org
Mon Dec 2 14:25:12 CET 2013

New issue 28: enhance tasklet.bind()

Anselm Kruis:

This issue proposes an enhancement for the method tasklet.bind(). It adds the functionality of tasklet.setup() except the implicit tasklet.insert() to bind().

The details were discussed on the Stackless mailing list in the thread http://www.stackless.com/pipermail/stackless/2013-November/005899.html. The credits for the idea to enhance tasklet.bind() go to Kristján: http://www.stackless.com/pipermail/stackless/2013-November/005911.html.

## Details ##

Currently tasklet.bind() requires a single positional argument. Kristján proposes to add two optional arguments. The signature of bind then becomes

```def bind(self, function, args=None, keywords=None):```

If both args and keywords are None, bind() behaves as before.
Otherwise presence of args and/or keywords as being non-None, would then
imply a setup, without scheduling the tasklet. In this case, if function is None the value of self.tempval is used as function, similar to tasklet.setup(). If self.tempval is None too, bind() raises RuntimeError('the tasklet was not bound to a function')

With this change tasklet.bind() and tasklet.insert() become the "atomic" building blocks for tasklet creation. tasklet.setup() is then equivalent to


def setup(self, *args, **kw):
    self.bind(None, args, kw)
    return self.insert()
## Plan ##

1. Implement the proposal and appropriate unit tests
2. Update the documentation in Doc/library/stackless/tasklets.rst and tasklet_state_chart.png
3. Update Stackless/changelog.txt
4. Port the change to Stackless version 3.x

Any objections?

Responsible: akruis

More information about the Stackless mailing list