[py-dev] py.execnet example bug

Ondrej Certik ondrej at certik.cz
Wed Aug 9 21:31:43 CEST 2006


Hi, I tried this example:

http://codespeak.net/py/current/doc/execnet.html#a-simple-and-useful-example-for-channels

and it seems it doesn't work for me -

I had to change this:

        for fn in channel.receive():
            f = open(fn, 'rb')
            try:
                channel.send(f.read())
            finally:
                f.close()

to this:

            try:
                while 1:
                    fn=channel.receive()
                    f = open(fn, 'rb')
                    try:
                        channel.send(f.read())
                    finally:
                        f.close()
            except:
                pass

to make it work. The problem is, that channel.receive() returns a
string (a filename), and the for loop then iterates over the
characters of the filename, which is obviously not what was intended.
Am I doing something wrong, or is it a bug?

Ondrej



More information about the Pytest-dev mailing list