Hi,

I'm currently opening issues to be addressed for 2.7.6-slp. Now I have a question about the proposed function/method "run_remove()"

1. Is run remove a function in module stackless or a method of class tasklet?

2. What's the difference to stackless.schedule_remove()? When to use the one, when the other? Could you use schedule_remove() instead of the proposed run_remove()?

I tried:
-----8<----------8<----------8<----------8<----------8<----------
$ arch/win32/bin/_fg2python.exe
Python 2.7.5 Stackless 3.1b3 060516 (default, Nov 6 2013, 18:20:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import stackless
>>> current=stackless.current
>>> def say_hello(): print "Hello, World!"
...
>>> t=stackless.tasklet(say_hello)()
>>> stackless.schedule_remove()
Hello, World!
<stackless.tasklet object at 0x02BDC6F0>
>>> current.alive
False
>>> stackless.current.alive
True
>>> stackless.current is current
False
>>> t.alive
False
>>> stackless.current is t
False
-----8<----------8<----------8<----------8<----------8<----------

So after stackless.schedule_remove() returned we have a new current tasklet and the previous current tasklet exited. I'm not sure, if this usage of schedule_remove() instead of stackless.run() is correct.

Cheers
  Anselm


Am 19.11.2013 12:16, schrieb Anselm Kruis:
Hi Kristján,

I wasn't aware of stackless.atomic(). It's not yet documented.

Obviously there are a few pending issues before we can release 2.7.6-slp.

- add set_args()
- add run_remove()
- update the documentation
- update the changelog

Anything else? We should really try to create a consistent and well
documented release.

Cheers
   Anselm


Am 19.11.2013 10:16, schrieb Kristján Valur Jónsson:
It does, inasmuch that the implicit "insert" that  exists on many
methods is indeed annoying.
But it is not really a problem, because:

def set_args(t, args=(), kw={}):
   with stackless.atomic():
     t.setup(*args, **kw):
     t.remove()


A more annoying problem that isn't solvable, and that is that there is
no run_remove(), i.e. no way switch to a tasklet and remove the caller
from the run queue.
This is something that is needed in stacklesslib.async:


def call_async(callable, args=(), kwargs={}):
     awaiter = Awaiter(stackless.getcurrent())
     callee = stackless.tasklet(async_call_helper)
     future = futures.Future()
     with atomic():
         callee(future, awaiter, callable, args, kwargs)
         try:
             # here, a run(remove=True) or a switch() primitive would
be useful
             callee.run()
         finally:
             # need this here, in case caller gets awoken by other
means, e.g. exception
             awaiter.caller_continued = True
     return future

def async_call_helper(future, awaiter, callable, args, kwargs):
     # remove the caller from the runnables queue.  There is a window
here where other tasklets
     # might run, we need perhaps a primitive to perform this task
     try:
         awaiter.caller.remove()



--
 Dipl. Phys. Anselm Kruis                       science + computing ag
 Senior Solution Architect                      Ingolstädter Str. 22
 email [email protected]             80807 München, Germany
 phone +49 89 356386 874  fax 737               www.science-computing.de
--
Vorstandsvorsitzender/Chairman of the board of management:
Gerd-Lothar Leonhart
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Michael Heinrichs, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Philippe Miltin
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196
_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to