[Stackless] Access to local variables of a task from tasklet

Najem Karim najemkarim at yahoo.com
Thu Jun 18 09:49:56 CEST 2009


Hello,

I have the following question:
Is there a way to access the local variables
of a tasklet.

I will explain with an example:

I have a task say:

def myTask1()
	localvar1 = 10
	....

I use it to create a tasklet say:
myTasklet1 = stackless.tasklet(myTask1)()

then run it with:
myTasklet1 = stackless.run(1)
to run one instruction and return.

Is possible now to use myTasklet1 to check/get the value of localvar1

I need this because at this point I would like to run another task which
needs the current value localvar1 as input parameter

say:
def myTask2(var1)
	....
	pass

Now get the value of localvar1 from myTasklet1 and store it in var1
then remove myTasklet1 from the list using:
myTasklet1.remove()

then create and run the second tasklet untill the end using:
myTasklet2 = stackless.tasklet(myTask2)(var1)
stackless.run()

Once myTasklet2 is done, I resume myTasklet1 were it stopped before using
myTasklet2.insert()
myTasklet1 = stackless.run(1)

then repeat allover again until myTasklet1 is finished

Is there a way to do this.

I appreciate any help.

Thanks


      




More information about the Stackless mailing list