This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 Jimbofbx
收信人 Jimbofbx, asksol, dragonfyre13, dsvensson, gsson, jnoller, jodal, pitrou, sbt
日期 2012-04-07.19:35:09
SpamBayes Score -1.0
Marked as misclassified
Message-id <1333827310.14.0.8522545144.issue4892@psf.upfronthosting.co.za>
In-reply-to
内容
Shouldn't reduce_pipe_connection just be an alias for reduce_connection in unix so that using reduce_pipe_connection would work for both win and unix? My understanding after looking at the code is that reduce_pipe_connection isn't defined for non-win32, although I haven't tested it to see if that's true.

Of course, ideally a pipe connection would just pickle and unpickle properly out-of-the-box, which I think was the original intent.

Here's a complete, working example with Python 3.2 tested on Win 7 64-bit:

import sys
from multiprocessing import Process,Pipe, reduction

def main():
    print("starting");
    i, o = Pipe(False)
    parent, child = Pipe();
    reducedchild = reduce_pipe(child);
    p = Process(target=helper, args=(i,));
    p.start();
    parent.send("hi");
    o.send(reducedchild);
    print(parent.recv());
    print("finishing");
    p.join();
    print("done");

def helper(inPipe):
    childPipe = expand_reduced_pipe(inPipe.recv());
    childPipe.send("child got: " + childPipe.recv());
    return;

def reduce_pipe(pipe):
    if sys.platform == "win32":
        return reduction.reduce_pipe_connection(pipe);
    else:
        return reduction.reduce_connection(pipe);

def expand_reduced_pipe(reduced_pipe):
    return reduced_pipe[0](*reduced_pipe[1]);

if __name__ == "__main__":
    main();
历史
日期 用户 动作 参数
2012-04-07 19:35:10Jimbofbx修改recipients: + Jimbofbx, pitrou, jnoller, gsson, dsvensson, asksol, jodal, dragonfyre13, sbt
2012-04-07 19:35:10Jimbofbx修改messageid: <1333827310.14.0.8522545144.issue4892@psf.upfronthosting.co.za>
2012-04-07 19:35:09Jimbofbx链接issue4892 messages
2012-04-07 19:35:09Jimbofbx创建