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()



-----Original Message-----
From: [email protected] [mailto:stackless-
[email protected]] On Behalf Of Anselm Kruis
Sent: 18. nóvember 2013 10:39
To: [email protected]
Subject: [Stackless] Proposal: new tasklet method set_args(*args, **kw)
that combines setup() and remove()

Hi,

I propose to add a new method set_args(*args, **kw) to class tasklet, that
combines

       stackless.setup(*args, **kw)
       stackless.remove()

Rationale: it is currently not possible to create an alive tasklet without
scheduling it (except via unpickling or direct __setstate__).

With the new bind_thread() method, one can think of use cases where one
thread creates tasklets and another thread executes them. No need to insert
these tasklets into the current run queue. It could even cause races.

With set_args() in place, setup() would become a simple shortcut for
set_args() followed by insert().

Does this proposal make sense?

regards
    Anselm

--
   Dipl. Phys. Anselm Kruis                       science + computing ag
   Senior Solution Architect                      Ingolstädter Str. 22
   email [email protected]<mailto:[email protected]>      
       80807 München, Germany
   phone +49 89 356386 874  fax 737               
www.science-computing.de<http://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]<mailto:[email protected]>
http://www.stackless.com/mailman/listinfo/stackless




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()
-----Original Message-----
From: [email protected] [mailto:stackless-
[email protected]] On Behalf Of Anselm Kruis
Sent: 18. nóvember 2013 10:39
To: [email protected]
Subject: [Stackless] Proposal: new tasklet method set_args(*args, **kw)
that combines setup() and remove()

Hi,

I propose to add a new method set_args(*args, **kw) to class tasklet, that
combines

       stackless.setup(*args, **kw)
       stackless.remove()

Rationale: it is currently not possible to create an alive tasklet without
scheduling it (except via unpickling or direct __setstate__).

With the new bind_thread() method, one can think of use cases where one
thread creates tasklets and another thread executes them. No need to insert
these tasklets into the current run queue. It could even cause races.

With set_args() in place, setup() would become a simple shortcut for
set_args() followed by insert().

Does this proposal make sense?

regards
   Anselm

--
  Dipl. Phys. Anselm Kruis                       science + computing ag
  Senior Solution Architect                      Ingolstädter Str. 22
  [email protected]
<mailto:[email protected]>             80807 München, Germany
  phone +49 89 356386 874  fax 737www.science-computing.de 
<http://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] <mailto:[email protected]>
http://www.stackless.com/mailman/listinfo/stackless


_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless


--
 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