<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>It does, inasmuch that the implicit "insert" that  exists on many methods is indeed annoying.</div>
<div>But it is not really a problem, because:</div>
<div> </div>
<div>def set_args(t, args=(), kw={}):</div>
<div>  with stackless.atomic():<br>

    t.setup(*args, **kw):</div>
<div>    t.remove()</div>
<div> </div>
<div> </div>
<div>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.</div>
<div>This is something that is needed in stacklesslib.async:</div>
<div> </div>
<div> </div>
<div>def call_async(callable, args=(), kwargs={}):</div>
<div>    awaiter = Awaiter(stackless.getcurrent())</div>
<div>    callee = stackless.tasklet(async_call_helper)</div>
<div>    future = futures.Future()</div>
<div>    with atomic():</div>
<div>        callee(future, awaiter, callable, args, kwargs)</div>
<div>        try:</div>
<div>            <span style="background-color:yellow;"># here, a run(remove=True) or a switch() primitive would be useful</span></div>
<div><span style="background-color:yellow;">            callee.run()</span></div>
<div>        finally:</div>
<div>            # need this here, in case caller gets awoken by other means, e.g. exception</div>
<div>            awaiter.caller_continued = True</div>
<div>    return future</div>
<div> </div>
<div>def async_call_helper(future, awaiter, callable, args, kwargs):</div>
<div>    # remove the caller from the runnables queue.  There is a window here where other tasklets</div>
<div>    # might run, we need perhaps a primitive to perform this task</div>
<div>    try:</div>
<div>        <span style="background-color:yellow;">awaiter.caller.remove()</span></div>
<div> </div>
<div> </div>
<div> </div>
<div>> -----Original Message-----</div>
<div>> From: stackless-bounces@stackless.com [<a href=""></a>mailto:stackless-</div>
<div>> bounces@stackless.com] On Behalf Of Anselm Kruis</div>
<div>> Sent: 18. nóvember 2013 10:39</div>
<div>> To: stackless@stackless.com</div>
<div>> Subject: [Stackless] Proposal: new tasklet method set_args(*args, **kw)</div>
<div>> that combines setup() and remove()</div>
<div>> </div>
<div>> Hi,</div>
<div>> </div>
<div>> I propose to add a new method set_args(*args, **kw) to class tasklet, that</div>
<div>> combines</div>
<div>> </div>
<div>>        stackless.setup(*args, **kw)</div>
<div>>        stackless.remove()</div>
<div>> </div>
<div>> Rationale: it is currently not possible to create an alive tasklet without</div>
<div>> scheduling it (except via unpickling or direct __setstate__).</div>
<div>> </div>
<div>> With the new bind_thread() method, one can think of use cases where one</div>
<div>> thread creates tasklets and another thread executes them. No need to insert</div>
<div>> these tasklets into the current run queue. It could even cause races.</div>
<div>> </div>
<div>> With set_args() in place, setup() would become a simple shortcut for</div>
<div>> set_args() followed by insert().</div>
<div>> </div>
<div>> Does this proposal make sense?</div>
<div>> </div>
<div>> regards</div>
<div>>    Anselm</div>
<div>> </div>
<div>> --</div>
<div>>   Dipl. Phys. Anselm Kruis                       science + computing ag</div>
<div>>   Senior Solution Architect                      Ingolstädter Str. 22</div>
<div>>   email <a href="mailto:A.Kruis@science-computing.de">A.Kruis@science-computing.de</a>             80807 München, Germany</div>
<div>>   phone +49 89 356386 874  fax 737               <a href="http://www.science-computing.de">www.science-computing.de</a></div>
<div>> --</div>
<div>> Vorstandsvorsitzender/Chairman of the board of management:</div>
<div>> Gerd-Lothar Leonhart</div>
<div>> Vorstand/Board of Management:</div>
<div>> Dr. Bernd Finkbeiner, Michael Heinrichs, Dr. Arno Steitz, Dr. Ingrid Zech</div>
<div>> Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board:</div>
<div>> Philippe Miltin</div>
<div>> Sitz/Registered Office: Tuebingen</div>
<div>> Registergericht/Registration Court: Stuttgart Registernummer/Commercial</div>
<div>> Register No.: HRB 382196</div>
<div>> </div>
<div>> </div>
<div>> _______________________________________________</div>
<div>> Stackless mailing list</div>
<div>> <a href="mailto:Stackless@stackless.com">Stackless@stackless.com</a></div>
<div>> <a href="http://www.stackless.com/mailman/listinfo/stackless">http://www.stackless.com/mailman/listinfo/stackless</a></div>
<div> </div>
<div> </div>
</span></font>
</body>
</html>