473,560 Members | 2,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: concurrency program design stackless python tasklet or pythonthread?

thank you very much for the advices!

I asked myself many times, why not just use thread:D

After some research I found thread has some fatal defects

1. thread number is limited by os, that means the system don't want
you start many threads at the same time
2. thread pool is another approach for concurrent program, but the
context switching could be very costy

so here comes stackless way?
On Wed, Nov 12, 2008 at 12:10 AM, Aleksandar Radulovic <al**@a13x.netw rote:
Hi there,

On Tue, Nov 11, 2008 at 5:57 AM, davy zhang <da*******@gmai l.comwrote:
>first here is my basic idea is every actor holds their own msg queue,
the process function will handle the message as soon as the dispatcher
object put the message in.

Using stackless, every tasklet can have a channel which it uses to communicate
with other tasklets. The tasklet is blocked until there's something on
the channel
to receive.
>This idea naturally leads me to place every actor in a separate thread
waiting for msg

You can have actors with many separate tasklets waiting for messages, still
being relatively lightweight, meaning you can run thousands of tasklets without
serious lack of performance.
>but I found the tasklet is really a lined-up sequence , that means if
a tasklet blocked or do some time consuming calculation, the other
tasklets can not get the cpu slice

This is cooperative scheduling, which you can choose not to use with Stackless
(instead, use preemptive scheduling). If you determine that one particular
task is taking too much cpu, you can declaratively call stackless.sched ule()
and put that task back to the scheduler queue and allow other tasks to
have a go.
>so we must design very carefully to avoid the big job for single task

That's right - with cooperative scheduling careful design is the key.
>I am just confused why the stackless python is said to be good at
concurrency program model or just I get a wrong idea to practice?

Stackless is an extremely lightweight way into concurrent programming.
I have personally used it in few projects and i quite like how lightweight
it is and how easy it is to write concurrent programs.

On the plus side, Stackless developers have plenty of examples and
common idioms of how Stackless should be used, which I highly recommend
you to check out. You might find a solution to your problem right there
amongst the examples.
Check it all out on http://www.stackless.com

--
a lex 13 x
http://www.a13x.info
--
http://mail.python.org/mailman/listinfo/python-list
Nov 13 '08 #1
0 1738

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1229
by: Christian Tismer | last post by:
Hi friends, for the last two+ weeks, I was hacking on the internals of stackless, in order to make things cleaner, smaller, more natural and more complete. This patch is a quite essential refactoring of the internals, enhancing functionality at the same time. On the other hand, semantics are almost not touched.
3
3674
by: Martin Evans | last post by:
I've just been tasked with porting our desktop embedded Python support onto our existing CE offering. I've managed to compile the Python sources and have produced an armdbg420\python23.lib file. When I come to link to the Python library though from our one of our DLLs, I am getting the following unresolved externals: -------------------...
2
1871
by: Michael Hudson | last post by:
The PyPy development team has been busy working and we've now packaged our latest improvements, completed work and new experiments as version 0.9.0, our fourth public release. The highlights of this fourth release of PyPy are: **implementation of "stackless" features** We now support the larger part of the interface of the original...
14
3423
by: fdu.xiaojf | last post by:
Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the program can save all running data to a file when I want it to stop, and can reload the data and continue to run from where it stops when the computer...
3
2970
by: archaegeo | last post by:
I am getting started in Python, and I have looked on both the stackless page and python.org and cannot find the answer to what I think is a simple problem. If I start the python command line or idle, i can If I start pythonwin I get the following error ....No Module named Stackless Any help?
6
1109
by: Justin T. | last post by:
Hi, I've been looking at stackless python a little bit, and it's awesome. My question is, why hasn't it been integrated into the upstream python tree? Does it cause problems with the current C-extensions? It seems like if something is fully compatible and better, then it would be adopted. However, it hasn't been in what appears to be 7...
0
938
by: Linnorm | last post by:
I've written a port forwarding wrapper with paramiko for an app we use and it works fine except that it consumes way too much processor. (i.e. 25% +) I'm trying to write a stackless-based server class to replace the threading one but I can't get the tunnel the wrapper creates to work for more than one instance of the app. I based my code on...
1
1889
by: davy zhang | last post by:
first here is my basic idea is every actor holds their own msg queue, the process function will handle the message as soon as the dispatcher object put the message in. This idea naturally leads me to place every actor in a separate thread waiting for msg but the rumor has it, stackless python with tasklet and channel can do much more...
0
1041
by: Aleksandar Radulovic | last post by:
Hi there, On Tue, Nov 11, 2008 at 5:57 AM, davy zhang <davyzhang@gmail.comwrote: Using stackless, every tasklet can have a channel which it uses to communicate with other tasklets. The tasklet is blocked until there's something on the channel to receive.
0
7631
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7840
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8063
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7595
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5175
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1168
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.