procedures and Nondeterminism

Consider the following program segment from IoTPy/IoTPy/tests/element_test.py

def test_multiple_relations_2():
    @map_e
    def double(v): return v*2
    x = Stream('x')
    y = Stream('y')
    double(x, y)
    double(x, y)
    x.extend(range(5))
    run()
    print recent_values(y)

This program has two instances of the statement double(x, y). Each call to double(x, y) creates an agent that appends twice the element that it reads on stream x on to stream y. This program terminates when both agents terminate at which point y will contain an interleaving of [0, 2, 4, 6, 8] generated by one agent, and [0, 2, 4, 6, 8] generated by the other agent. The interleaving is not deterministic. Some example values of y are [0, 2, 4, 6, 8, 0, 2, 4, 6, 8] or [0, 2, 0, 2, 4, 4, 6, 8, 6, 8].