1.1 --- a/parallel.py Tue Sep 27 17:28:25 2005 +0000
1.2 +++ b/parallel.py Tue Sep 27 18:04:03 2005 +0000
1.3 @@ -78,6 +78,15 @@
1.4
1.5 http://mail.python.org/pipermail/python-dev/2002-September/028572.html
1.6 http://twistedmatrix.com/bugs/issue733
1.7 +
1.8 +Select and Poll
1.9 +---------------
1.10 +
1.11 +The exact combination of conditions indicating closed pipes remains relatively
1.12 +obscure. Here is a message/thread describing them (in the context of another
1.13 +topic):
1.14 +
1.15 +http://twistedmatrix.com/pipermail/twisted-python/2005-February/009666.html
1.16 """
1.17
1.18 import os
1.19 @@ -121,15 +130,15 @@
1.20 self.closed = 1
1.21 self.read_pipe.close()
1.22 self.write_pipe.close()
1.23 - self.wait()
1.24 + self.wait(os.WNOHANG)
1.25
1.26 - def wait(self):
1.27 + def wait(self, options=0):
1.28
1.29 "Wait for the created process, if any, to exit."
1.30
1.31 if self.pid != 0:
1.32 try:
1.33 - os.waitpid(self.pid, os.WNOHANG)
1.34 + os.waitpid(self.pid, options)
1.35 except OSError:
1.36 pass
1.37
1.38 @@ -219,8 +228,12 @@
1.39
1.40 pid = os.fork()
1.41 if pid == 0:
1.42 + os.close(parent_read_fd)
1.43 + os.close(parent_write_fd)
1.44 return Channel(pid, os.fdopen(child_read_fd, "r"), os.fdopen(child_write_fd, "w"))
1.45 else:
1.46 + os.close(child_read_fd)
1.47 + os.close(child_write_fd)
1.48 return Channel(pid, os.fdopen(parent_read_fd, "r"), os.fdopen(parent_write_fd, "w"))
1.49
1.50 def start(callable, *args, **kwargs):
1.51 @@ -243,7 +256,7 @@
1.52 channel.send(exc_value)
1.53 finally:
1.54 channel.close()
1.55 - raise SystemExit
1.56 + sys.exit(0)
1.57 else:
1.58 return channel
1.59