# HG changeset patch # User paulb # Date 1212953735 0 # Node ID 36762cec961ae3afd21815d58d08906d57093493 # Parent eeaa043dbfb13f83002d7a3871425e386af09efd [project @ 2008-06-08 19:35:35 by paulb] Added workaround for broken Solaris socketpair/poll using pipes. diff -r eeaa043dbfb1 -r 36762cec961a README.txt --- a/README.txt Wed Jun 04 22:13:31 2008 +0000 +++ b/README.txt Sun Jun 08 19:35:35 2008 +0000 @@ -152,6 +152,8 @@ * Added a utility function to detect and return the number of processor cores available. * Added missing documentation stylesheet. + * Added support for Solaris using pipes instead of socket pairs, since + the latter do not apparently work properly with poll on Solaris. New in pprocess 0.3.1 (Changes since pprocess 0.3) -------------------------------------------------- diff -r eeaa043dbfb1 -r 36762cec961a pprocess.py --- a/pprocess.py Wed Jun 04 22:13:31 2008 +0000 +++ b/pprocess.py Sun Jun 08 19:35:35 2008 +0000 @@ -26,6 +26,7 @@ import sys import select import socket +import platform try: import cPickle as pickle @@ -854,7 +855,7 @@ # Low-level functions. -def create(): +def create_socketpair(): """ Create a new process, returning a communications channel to both the @@ -873,6 +874,34 @@ child.close() return Channel(pid, parent.makefile("r", 0), parent.makefile("w", 0)) +def create_pipes(): + + """ + Create a new process, returning a communications channel to both the + creating process and the created process. + + This function uses pipes instead of a socket pair, since some platforms + seem to have problems with poll and such socket pairs. + """ + + pr, cw = os.pipe() + cr, pw = os.pipe() + + pid = os.fork() + if pid == 0: + pr.close() + pw.close() + return Channel(pid, os.fdopen(cr, "r", 0), os.fdopen(cw, "w", 0)) + else: + cr.close() + cw.close() + return Channel(pid, os.fdopen(pr, "r", 0), os.fdopen(pw, "w", 0)) + +if platform.system() == "SunOS": + create = create_pipes +else: + create = create_socketpair + def create_persistent(address): """