[pypy-dev] Syntax for the 'transaction' module

Laura Creighton lac at openend.se
Thu May 3 12:38:16 CEST 2012


In a message of Wed, 02 May 2012 09:22:03 +0200, Armin Rigo writes:
>Hi Laura,
>
>A note on my two previous messages: in the first one I argued about
>@breakable, while the second one I suggested to use threads and "with
>atomic".  The relationship between the two is: in the first model you
>would put @breakable on some outer functions until it calls things
>that are supposed to be atomic; in the second model you would identify
>the call in question and put "with atomic" there.  I would personally
>prefer @breakable because it forces the "atomic by default" idea a bit
>further, but I fear that the second model is better because it is
>fully compatible with existing programs.  Moreover, as I argue
>repeatedly, regular apps should use neither, and only library
>implementors should have to worry.
>
>
>A bientôt,
>
>Armin.

As promised, I have been doing more thinking while paddling.  We
camped out in Göteborg's archipelago and the island, as is common, has
sheep.  It occured to me that what we have is very like a shepherding
problem.  Since my uncle raised sheep, I have some personal experience
with these problems from my childhood.

1.  Assume you have 2 pastures, with a gate between them, and a flock 
of sheep.  Your flock is in one pasture, and you want to get them to
the other pasture through the gate.

2.  Sheep are, to use the terms we have been using, 'unbreakable', and
'atomic'.  (If you slice them into pieces to try to get them to fit
through the gate, you will end up with non-functioning sheep on the other
side). :-)

3. If your gate is narrow, you will have to serialise your sheep, and
have them pass through one at a time.

4. If it is wider then parts of different sheep will pass through the
gate intermingled from the perspective of a camera mounted on the
gate.  "Nose of sheep 1, nose of sheep 2, head of sheep 1, nose of
sheep 3, head of sheep 3, body of sheep 3, tail of sheep 3, body of
sheep 2, body of sheep 1, tail of sheep 2, tail of sheep 1" is what
the camera might report as 'having gone passed', and we might conclude
that sheep 3 is a small lamb, and that sheep 1 is its mother who
slowed down going through the gate so that the lamb could keep up with
her -- but all of this doesn't matter because, as long as you do not
try to break them, the flock will function perfectly on the other side
of the gate without any attention being paid to them by you.

The main problem you have in moving pastures like this, as a shepherd,
is that ewes (mother sheep) normally have twins or triplets (at least
with the breed that my Uncle raised).  Hungry lambs want to find their
mothers right away, but the rest of the time they are busy frolicking
with other lambs, butting heads, chasing each other, and doing other
jeuvenile sheep things.  They don't play with their siblings any more
than with the other lambs.  Ewes, on the other hand, want their own
offspring close together, and with them all the time.  The mechanism
that the sheep use to keep track of each other is to bleat.  Each lamb
knows the sound of its mother's voice, and each ewe knows the sound of
its own lambs'.  They bleat more or less constantly when then are
moving from a part of the pasture to another, and of course when they
are being moved -- and they aren't all that quiet when grazing,
either.

If you are moving sheep through a gate, and it turns out that you have one
lamb in the new pasture while it's sibling(s) are in the old pasture you can
freeze your whole operation.  The mother ewe will stand in your gate and 
refuse to move until she is reunited with all her lambs, which might be
impossible if your gate is narrow.  I don't think we have anything like
this in our model, though maybe there is something analogous to bleating.

Do we need to handle the case of bits of code that are themselves
atomic that depend on being run with other bits of code in a
predictable sequence, or one of several possible sequences?

But you don't 'lock sheep', or sheep families.  All you can do is try
to submit them to the gate again.  And from personal experience, it
would be *very* *very* useful if you could magically restore the lamb
that is early into the new pasture into the old pasture, right beside
its mother.  (Of course then you would just be able to teleport the
whole lot and go away with gates altogether).

At any rate, if we want to discourage people from using what they
think they already know about concurrency and locking and whatnot, we
might want to talk about what we are doing as herding a flock of
<whatever we call the atomic series of instructions>.  I'm pretty sure
that this language isn't already being used somewhere to mean
something else, at any rate. :-) You (or mostly your dogs) 'drive' and
'fetch' sheep through gates -- driving is away from the shepherd and
fetching is towards the shepherd -- and you gather individual sheep
into a flock.

www.herding-dog-training-border-collie-sheepdog-dvd.com/herding_sheepdog_command_terminology.htm

has some other interesting -- but I doubt useful words.

But maybe, instead of scheduling, we are gathering?

Not sure any of this helps at all,
Laura




More information about the pypy-dev mailing list