# HG changeset patch # User paulb # Date 1127923206 0 # Node ID 5cd8b607d00ec718853da34d803af6a25f2b6825 # Parent c34dad3cdba9b78a0d0c6dcc420068d448cddab7 [project @ 2005-09-28 16:00:06 by paulb] Reduced the sockets opened for a channel to a single pair. Removed the redundant signal handling code. diff -r c34dad3cdba9 -r 5cd8b607d00e parallel.py --- a/parallel.py Wed Sep 28 15:56:36 2005 +0000 +++ b/parallel.py Wed Sep 28 16:00:06 2005 +0000 @@ -93,7 +93,6 @@ import sys import select import socket -#from signal import signal, SIGCHLD try: import cPickle as pickle @@ -225,20 +224,17 @@ creating process and the created process. """ - parent_read, child_write = socket.socketpair() - child_read, parent_write = socket.socketpair() - for s in [parent_read, child_write, child_read, parent_write]: + parent, child = socket.socketpair() + for s in [parent, child]: s.setblocking(1) pid = os.fork() if pid == 0: - parent_read.close() - parent_write.close() - return Channel(pid, child_read.makefile("r"), child_write.makefile("w")) + parent.close() + return Channel(pid, child.makefile("r"), child.makefile("w")) else: - child_read.close() - child_write.close() - return Channel(pid, parent_read.makefile("r"), parent_write.makefile("w")) + child.close() + return Channel(pid, parent.makefile("r"), parent.makefile("w")) def start(callable, *args, **kwargs): @@ -264,11 +260,4 @@ else: return channel -# Define and install a handler which waits for terminated child processes. - -#def handler(number, frame): -# os.wait() - -#signal(SIGCHLD, handler) - # vim: tabstop=4 expandtab shiftwidth=4