<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Andrew,<br>
<br>
thanks for this input. The was one little snag, an infinite loop of
stackless.schedule() pust CPU load at 100%. So I now solved it like
this:<br>
<tt>def run(self):<br>
.....</tt><br>
<tt> switchboard=stackless.tasklet(self.switchboard)
<br>
switchboard.setup()
<br>
while self.NotDead:
<br>
if stackless.getruncount()>1:
<br>
stackless.schedule()
<br>
else:
<br>
time.sleep(0.0001)
<br>
<br>
def switchboard(self):
<br>
while self.NotDead:
<br>
try:
<br>
bla=self.workerQueue.get() <br>
(returnQueue,cmdLink,callme,params)=bla<br>
t=stackless.tasklet(self.runner)<br>
t.setup(returnQueue,callme,params)
<br>
stackless.schedule()<br>
<br>
...etc...<br>
</tt><br>
where workerqueue.get() ends up being a channel.receive()<br>
<br>
My code runs again, until now without deadlocking!<br>
<br>
Andrew Francis wrote:
<blockquote cite="mid:972196.4700.qm@web34204.mail.mud.yahoo.com"
type="cite">
<pre wrap="">Hi Paul:
</pre>
<blockquote type="cite">
<pre wrap="">Message: 7
Date: Tue, 17 Mar 2009 09:59:09 +0100
From: Paul Sijben <a class="moz-txt-link-rfc2396E" href="mailto:sijben@eemvalley.com"><sijben@eemvalley.com></a>
Subject: Re: [Stackless] stackless inter-thread queues
To: Richard Tew <a class="moz-txt-link-rfc2396E" href="mailto:richard.m.tew@gmail.com"><richard.m.tew@gmail.com></a>
Cc: <a class="moz-txt-link-abbreviated" href="mailto:stackless@stackless.com">stackless@stackless.com</a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:49BF665D.20807@eemvalley.com"><49BF665D.20807@eemvalley.com></a>
Content-Type: text/plain; charset="iso-8859-1"
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
<blockquote type="cite">
<pre wrap="">Hi Richard,
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
<blockquote type="cite">
<pre wrap="">Being faced with the situation that I need queue-like behaviour, so one
tasklet needs to be waiting on the channel and in some cases this is the
only tasklet.
</pre>
</blockquote>
<pre wrap=""><!---->
Paul you should be looking to see why other tasklets don't rendezvous with the waiting tasklet's channel?
</pre>
<blockquote type="cite">
<pre wrap="">Is there a way I can make a dummy tasklet to be scheduled when there is
noting else to do? But one that does not load the CPU?
</pre>
</blockquote>
<pre wrap=""><!---->
Paul, it has been a while since I played with threads and stackless. I found threads and queues typically hid a design problem. Then again, I haven't used UIs.
I believe to keep the application alive, I did something like:
<your code goes here>
while flag:
stackless.schedule()
in the main tasklet. If there is nothing, only the main tasklet gets scheduled. I believe there is an example in the Stackless Google repository.
Again, I would have to look at the code. However when you need queues and dummy tasklets, it sounds like there is a more straightforward solution.
Cheers,
Andrew
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Paul Sijben         tel: +31334566488
Eemvalley Technology BV         fax: +31334557523
the Netherlands         <a class="moz-txt-link-freetext" href="http://eemvalley.com">http://eemvalley.com</a>
-----------------------------------------------------
EemValley Technology werft python & wxpython
programmeurs: <a class="moz-txt-link-freetext" href="http://www.eemvalley.nl/jobs">http://www.eemvalley.nl/jobs</a>
</pre>
</body>
</html>