473,385 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Greenlets: where are they now???

Hi,

A few weeks ago, I discovered Armin Rigo's greenlets and thought they were
brilliant. I'm seriously thinking about using them, and at least someone
else is

http://www.eby-sarna.com/pipermail/p...st/001720.html

Currently, I understand that Greenlets are more-or-less hidden from the
public eye in the Stackless CVS, even though they compile and work like a
charm with regular CPython. Given all the desire for full coroutines that I
hear on Python-dev, greenlets strike me as genuine "hidden treasure." Here
is my point:

A) Why aren't greenlets being considered as a solution to coroutines? (Do
people feel that "hacking the C stack is bad" is a compelling argument? It
strikes me that any coroutine implementation in CPython will have to do
this.)

B) Will a later version of CPython support greenlets natively? (in
particular by adding the appropriate entries to PyThreadState)

C) Will greenlets ever be released? Is there a ToDo list that prevents their
release?

D) How did he come up with a cool name like "Greenlet"?

Cheers,
David
Jul 18 '05 #1
11 2078
David Pokorny wrote:
A) Why aren't greenlets being considered as a solution to coroutines?
Maybe because coroutines aren't a problem that needs to be solved. :-)
Seriously though, what is the actual problem to which you feel
greenlets are a good solution? Answering that might reveal that
relatively few people actually face the problem described,
thus few people bother with its solution...
D) How did he come up with a cool name like "Greenlet"?


"Green threads" is a term that is fairly widely used for
non-native (non-OS) threads, though I have no idea of the
origin. Presumably these are a lightweight type of non-
native thread, thus greenlet.

-Peter
Jul 18 '05 #2

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:x6********************@powergate.ca...
Seriously though, what is the actual problem to which you feel
greenlets are a good solution?


Greenlets are about 90% of a solution (which I've thought hard about) to the
problem of interrupting an execution after 50 byte-code, while retaining the
ability to resume the execution (for, say, another 50 byte codes).

The main requirements of the solution are:

- it work with regular CPython with minimal tinkering (some tinkering of
ceval.c is necessary).

- it not do any "reimplementing eval," i.e. I'm not in the business of
second-guessing PyEval_EvalFrame.

....

In other words, my message may have implied that I'm concerned with other
people's uses for coroutines. I'm actually much more interested in hearing
Armin Rigo comment on the development status of Greenlets.

BTW, the code that ultimately will get interrupted every 50 byte codes is
not my own---it will be Python bots, written by users... ...friendly
users... (<suspicious glance at deprecated rexec>)

David
Jul 18 '05 #3
David Pokorny wrote:
"Peter Hansen" <pe***@engcorp.com> wrote in message
news:x6********************@powergate.ca...
Seriously though, what is the actual problem to which you feel
greenlets are a good solution?


Greenlets are about 90% of a solution (which I've thought hard about) to the
problem of interrupting an execution after 50 byte-code, while retaining the
ability to resume the execution (for, say, another 50 byte codes).


Python's regular threads already allow this, so there must be
something more to it.

-Peter
Jul 18 '05 #4
"David Pokorny" <da******@soda.csua.berkeley.edu> writes:
Hi,

A few weeks ago, I discovered Armin Rigo's greenlets and thought they were
brilliant. I'm seriously thinking about using them, and at least someone
else is

http://www.eby-sarna.com/pipermail/p...st/001720.html

Currently, I understand that Greenlets are more-or-less hidden from the
public eye in the Stackless CVS, even though they compile and work like a
charm with regular CPython. Given all the desire for full coroutines that I
hear on Python-dev, greenlets strike me as genuine "hidden treasure." Here
is my point:

A) Why aren't greenlets being considered as a solution to coroutines? (Do
people feel that "hacking the C stack is bad" is a compelling argument? It
strikes me that any coroutine implementation in CPython will have to do
this.)
I think the answer to your parenthetical question is "yes".
B) Will a later version of CPython support greenlets natively? (in
particular by adding the appropriate entries to PyThreadState)
Pass.

"It is tough to make predictions, especially about the future."
-- Yogi Berra
C) Will greenlets ever be released? Is there a ToDo list that prevents their
release?
I think lack of tuits is the main thing. I don't know if there are
obscure bugs or something like that.
D) How did he come up with a cool name like "Greenlet"?


Like Peter said, I presume it's a play on "green threads".

I'm fairly sure that (a) the only person who can really answer your
questions is Armin himself and (b) Armin doesn't read
comp.lang.python. I'll try to catch him on IRC and point him here,
but you might want to email him yourself...

Cheers,
mwh

--
<spiv> As far as I'm concerned, the meat pie is the ultimate unit
of currency. -- from Twisted.Quotes
Jul 18 '05 #5

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:29********************@powergate.ca...
Greenlets are about 90% of a solution (which I've thought hard about) to the problem of interrupting an execution after 50 byte-code, while retaining the ability to resume the execution (for, say, another 50 byte codes).


Python's regular threads already allow this, so there must be
something more to it.


I haven't the faintest idea how to gain fine control over threads. In
particular, suppose I have 10 of these "executions" going (lets call them
"steplets") and I want to run each of them for 50 byte-codes, then switch
back to the controlling thread and do lots of bookkeeping (I don't control
the code that the steplets run). I also have a bunch of other processes that
I don't want to take part in this "cycle rationing" but rather run as honest
threads.

David
Jul 18 '05 #6
Michael Hudson <mw*@python.net> wrote in message news:<m3************@pc150.maths.bris.ac.uk>...
"It is tough to make predictions, especially about the future."
-- Yogi Berra


I think I saw this attributed to Nils Bohr. Can somebody check?

Michele Simionato
Jul 18 '05 #7
David Pokorny wrote:
"Peter Hansen" <pe***@engcorp.com> wrote:
Python's regular threads already allow this, so there must be
something more to it.
I haven't the faintest idea how to gain fine control over threads.


Not sure what you mean by "fine control". I was reacting to the
"run for 50 bytecodes" part, which is something all threads do,
based on the current value of sys.setcheckinterval() (which defaults
to 100 now, if I recall correctly).
In
particular, suppose I have 10 of these "executions" going (lets call them
"steplets") and I want to run each of them for 50 byte-codes, then switch
back to the controlling thread and do lots of bookkeeping (I don't control
the code that the steplets run).
Not exactly something regular threads let you do under direct control,
though of course the main thread will run in due course anyway.
I also have a bunch of other processes that
I don't want to take part in this "cycle rationing" but rather run as honest
threads.


It almost sounds like you want to do this to prevent these other
threads from being able to take up too much CPU time. I don't
believe the greenlets approach would necessarily guarantee that,
either, since there are bytecodes that can consume unbounded
amounts of time.

You've described the characteristics that you think your
solution requires, but still not the actual problem. I suspect
the application you have is similar to ones where the usual
response in this newsgroup has been to point out that ultimately
only running this stuff in another process will provide the
guarantees you might need. (Though this "fine-grained control
with bookkeeping" thing is a little different from the usual
requests.)

-Peter
Jul 18 '05 #8
[Michael Hudson]
"It is tough to make predictions, especially about the future."
-- Yogi Berra

[Michele Simionato] I think I saw this attributed to Nils Bohr. Can somebody check?


Or was it Enrico Fermi? Winston Churchill? Vint Cerf? Groucho Marx?

http://www.larry.denenberg.com/predictions.html

regards,

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Jul 18 '05 #9
mi***************@gmail.com (Michele Simionato) writes:
Michael Hudson <mw*@python.net> wrote in message news:<m3************@pc150.maths.bris.ac.uk>...
"It is tough to make predictions, especially about the future."
-- Yogi Berra


I think I saw this attributed to Nils Bohr. Can somebody check?


Hmm. I already had :) but googling just now found this page:

http://www.larry.denenberg.com/predictions.html

which attributes variations on the above sentiment to just about
everyone you've ever heard of.

The phrasing above is certainly attributed to Yogi Berra pretty often.
Bohr is more likely to have the wildly different phrase:

"Prediction is very difficult, especially about the future."

attributed to him :)

It's a fairly obvious thought, after all.

Cheers,
mwh

--
"Sturgeon's Law (90% of everything is crap) applies to Usenet."
"Nothing guarantees that the 10% isn't crap, too."
-- Gene Spafford's Axiom #2 of Usenet, and a corollary
Jul 18 '05 #10
On Mon, Sep 13, 2004 at 08:12:07PM -0700, David Pokorny wrote:

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:29********************@powergate.ca...
Greenlets are about 90% of a solution (which I've thought hard about)to the problem of interrupting an execution after 50 byte-code, while retaining the ability to resume the execution (for, say, another 50 byte codes).


Python's regular threads already allow this, so there must be
something more to it.


I haven't the faintest idea how to gain fine control over threads. In
particular, suppose I have 10 of these "executions" going (lets call them
"steplets") and I want to run each of them for 50 byte-codes, then switch
back to the controlling thread and do lots of bookkeeping (I don't control
the code that the steplets run). I also have a bunch of other processes that
I don't want to take part in this "cycle rationing" but rather run as honest
threads.


wouldn't calling setcheckinterval with some ridiculously large
argument on entering the loop and setting it back to 100 (or 50) on
exit be enough?

--
John Lenton (jo**@grulic.org.ar) -- Random fortune:
Q: How many Marxists does it take to screw in a light bulb?
A: None: The light bulb contains the seeds of its own revolution.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBRuw3gPqu395ykGsRAp9XAJ9MxuidjMLf4DYh8T6N8d knfsNBgQCgwRPf
/to9f2mephasn7V56+U2r7M=
=nIMh
-----END PGP SIGNATURE-----

Jul 18 '05 #11

"Peter Hansen" <pe***@engcorp.com> wrote in message
news:O8********************@powergate.ca...
I don't
believe the greenlets approach would necessarily guarantee that,
either, since there are bytecodes that can consume unbounded
amounts of time.

You've described the characteristics that you think your
solution requires, but still not the actual problem.


Here's the idea: the executions I want to step through are bots that are
competing, 1 on 1, in a mathematical game (or otherwise, perhaps simulated
tag). Here is a good (and old) example

http://soda.csua.berkeley.edu/~davebrok/knobeln.txt

To answer your first point, although I do not write the bot code, anyone can
look at it, and in particular anyone can verify that no "cheating" occurs
along the lines of performing serious number crunching in a single bytecode
(via a C extension---AFAIK this is the main loophole in the
unbounded-execution-time-for-a-single-bytecode department).

David
Jul 18 '05 #12

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

Similar topics

0
by: Cameron Laird | last post by:
QOTW: "he essence of software development is code/task factorization." Hung Jung Lu "se the best tool for the job, and don't use any that preclude you from using others at the same time as...
0
by: Cameron Laird | last post by:
QOTW: "The advantage of using slices to extract a single element is that it avoids IndexErrors for empty lists." Raymond Hettinger http://groups.google.com/groups?th=44bd04fe85d02c19 "Usually...
1
by: Michele Simionato | last post by:
This should go in a blog, but I do not have one, nor any intention to start one, so I thought I will post here instead. Warning: this is a long post! ACCU Conference (PyUK) 2005: a personal...
3
by: Michael Sparks | last post by:
Hi, I'm posting a link to this since I hope it's of interest to people here :) I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework, and it's been published as a BBC...
15
by: Peter Tillotson | last post by:
Hi, I'm looking for an advanced concurrency module for python and don't seem to be able to find anything suitable. Does anyone know where I might find one? I know that there is CSP like...
61
by: km | last post by:
Hi all, is true parallelism possible in python ? or atleast in the coming versions ? is global interpreter lock a bane in this context ? regards, KM
11
by: binarybana | last post by:
After recently getting excited about the possibilities that stackless python has to offer (http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/) and then...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.