Re: Python and greenlets

  • From: Antti Kantee <pooka@xxxxxx>
  • To: rumpkernel-users@xxxxxxxxxxxxx
  • Date: Wed, 7 Sep 2016 12:44:41 +0000

On 05/09/16 19:53, Ryan Day wrote:

Once the build is complete, greenlets is available as a builtin. The
example in examples/ almost works. I think the final "78" line is not being
printed even though it should be. This brings us to the discussion part,
and why I moved to the list :)

Looking at the code:

=== snip ===
def test1():
    print(12)
    gr2.switch()
    print(34)

def test2():
    print(56)
    gr1.switch()
    print(78)


gr1 = greenlet(test1)
gr2 = greenlet(test2)

if __name__ == '__main__':
    hello_world()
    gr1.switch()
=== snip ===

Ignoring hello_world(), I'd expect that program to output:

12
56
34

What is it actually printing?

Other related posts: