[From nobody Sat Mar 13 18:14:47 2010
Return-path: &lt;Jimsfba@aol.com&gt;
From: Jimsfba@aol.com
Full-name: Jimsfba
Message-ID: &lt;be3.2a4a972.32603194@aol.com&gt;
Date: Thu, 12 Oct 2006 20:02:28 EDT
Subject: pause execusion of tasklet using remove()
To: stackless@stackless.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary=&quot;-----------------------------1160697748&quot;
X-Mailer: 9.0 SE for Windows sub 5026


-------------------------------1160697748
Content-Type: text/plain; charset=&quot;US-ASCII&quot;
Content-Transfer-Encoding: 7bit

Hi, I have a situation that 1,000,000 tasklets are making frequent calls to  
remote servers and waiting for reply. Each tasket is waiting for its own  
reply.  These tasklets are also created and removed frequently.

By  checking stackless's doc, I know I can create a new channel for each new 
tasklet  for making blocking call and make itself pause/sleep.

But it looks like  creating another model can make the code simpler and I 
don't have to create  1,000,000 channel objects.: 
1. after sending out request, pause the  tasklet  by using remove() call
2. use a reply manager to process reply  messages and wake up ( tasklet.run() 
) the specific tasklet based on taskletID  in the reply
3. reply manager kill taskets if they timeout ( I didn't see  channel have 
build-in timeout setting)

Please let me know I went to the  wrong path because of misunderstanding.

When looking at the remove() api,  I saw the following warning message about 
it:

|  remove(...)
|       Removing a tasklet from the runnables queue.
|      Note: If this tasklet has a non-trivial C stack  attached,
|      it will be  destructed when the containing thread state is  destroyed.
|      Since  this will happen in some unpredictable order, it may cause  
unwanted
|       side-effects. Therefore it is recommended to either run tasklets to  
the
|      end or to  explicitly kill() them.

Does it mean it's not recommended to use remove()  if I am not sure about if 
non-trivial C stack has been attached ? 

If  anyone can explain what is &quot;containing thread&quot; ( for example, is it a 
thread  generated by stackless internally ?  the main watchdog thread or the  
calling function of python?) and give an example how remove() might failed, I  
will really appreciate. 

Thanks in advanced.

-  Jim



-------------------------------1160697748
Content-Type: text/html; charset=&quot;US-ASCII&quot;
Content-Transfer-Encoding: quoted-printable

&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;HTML&gt;&lt;HEAD&gt;
&lt;META http-equiv=3DContent-Type content=3D&quot;text/html; charset=3DUS-ASCII&quot;&gt;
&lt;META content=3D&quot;MSHTML 6.00.2900.2802&quot; name=3DGENERATOR&gt;&lt;/HEAD&gt;
&lt;BODY id=3Drole_body style=3D&quot;FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY:=20=
Arial&quot;=20
bottomMargin=3D7 leftMargin=3D7 topMargin=3D7 rightMargin=3D7&gt;&lt;FONT id=3Drol=
e_document=20
face=3DArial color=3D#000000 size=3D2&gt;
&lt;DIV&gt;Hi, I have a situation that 1,000,000 tasklets are making frequent call=
s to=20
remote servers and waiting for reply. Each tasket is waiting for its own=20
reply.&amp;nbsp; These tasklets are also created and removed frequently.&lt;BR&gt;&lt;BR&gt;=
By=20
checking stackless's doc, I know I can create a new channel for each new tas=
klet=20
for making blocking call and make itself pause/sleep.&lt;BR&gt;&lt;BR&gt;But it looks li=
ke=20
creating another model can make the code simpler and I don't have to create=20
1,000,000 channel objects.: &lt;BR&gt;1. after sending out request, pause the=20
tasklet&amp;nbsp; by using remove() call&lt;BR&gt;2. use a reply manager to process re=
ply=20
messages and wake up ( tasklet.run() ) the specific tasklet based on tasklet=
ID=20
in the reply&lt;BR&gt;3. reply manager kill taskets if they timeout ( I didn't see=
=20
channel have build-in timeout setting)&lt;BR&gt;&lt;BR&gt;Please let me know I went to t=
he=20
wrong path because of misunderstanding.&lt;BR&gt;&lt;BR&gt;When looking at the remove()=20=
api,=20
I saw the following warning message about it:&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp=
;=20
|&amp;nbsp; remove(...)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nb=
sp;=20
Removing a tasklet from the runnables queue.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=20
|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Note: If this tasklet has a non-trivial C st=
ack=20
attached,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; it wil=
l be=20
destructed when the containing thread state is=20
destroyed.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Since=
=20
this will happen in some unpredictable order, it may cause=20
unwanted&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=20
side-effects. Therefore it is recommended to either run tasklets to=20
the&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end or to=20
explicitly kill() them.&lt;BR&gt;&lt;BR&gt;Does it mean it's not recommended to use remo=
ve()=20
if I am not sure about if non-trivial C stack has been attached ? &lt;BR&gt;&lt;BR&gt;If=
=20
anyone can explain what is &quot;containing thread&quot; ( for example, is it a thread=
=20
generated by stackless internally ?&amp;nbsp; the main watchdog thread or the=20
calling function of python?) and give an example how remove() might failed,=20=
I=20
will really appreciate. &lt;BR&gt;&lt;BR&gt;Thanks in advanced.&lt;BR&gt;&lt;BR&gt;-=20
Jim&lt;BR&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;/FONT&gt;&lt;/BODY&gt;&lt;/HTML&gt;

-------------------------------1160697748--
]