parameters: (argv, env)
docstring: Pipe spawn
docstring_summary: Pipe spawn
docstring_tokens: Pipe spawn
function: def _pipespawn(argv, env):
      """ Pipe spawn """
      # pylint: disable = R0912
      import pickle as _pickle
      fd, name = mkstemp('.py')
      try:
          _os.write(fd, (r"""
  import os
  import pickle
  try:
      import subprocess
  except ImportError:
      subprocess = None
  import sys
  
  argv = pickle.loads(%(argv)s)
  env = pickle.loads(%(env)s)
  if 'X_JYTHON_WA_PATH' in env:
      env['PATH'] = env['X_JYTHON_WA_PATH']
  
  if subprocess is None:
      pid = os.spawnve(os.P_NOWAIT, argv[0], argv, env)
      result = os.waitpid(pid, 0)[1]
  else:
      p = subprocess.Popen(argv, env=env)
      result = p.wait()
      if result < 0:
          print "\n%%d 1" %% (-result)
          sys.exit(2)
  
  if result == 0:
      sys.exit(0)
  signalled = getattr(os, 'WIFSIGNALED', None)
  if signalled is not None:
      if signalled(result):
          print "\n%%d %%d" %% (os.WTERMSIG(result), result & 7)
          sys.exit(2)
  print "\n%%d" %% (result & 7,)
  sys.exit(3)
          """.strip() + "\n") % {
              'argv': repr(_pickle.dumps(argv)),
              'env': repr(_pickle.dumps(env)),
          })
          fd, _ = None, _os.close(fd)
          if _sys.platform == 'win32':
              argv = []
              for arg in [_sys.executable, name]:
                  if ' ' in arg or arg.startswith('"'):
                      arg = '"%s"' % arg.replace('"', '\\"')
                  argv.append(arg)
              argv = ' '.join(argv)
              shell = True
              close_fds = False
          else:
              argv = [_sys.executable, name]
              shell = False
              close_fds = True
  
          res = 0
          try:
              import subprocess
          except ImportError:
              import popen2 as _popen2
              proc = _popen2.Popen3(argv, False)
              try:
                  proc.tochild.close()
                  result = proc.fromchild.read()
              finally:
                  res = proc.wait()
          else:
              if 'X_JYTHON_WA_PATH' in env:
                  env['PATH'] = env['X_JYTHON_WA_PATH']
  
              proc = subprocess.Popen(argv,
                  shell=shell,
                  stdin=subprocess.PIPE,
                  stdout=subprocess.PIPE,
                  close_fds=close_fds,
                  env=env,
              )
              try:
                  proc.stdin.close()
                  result = proc.stdout.read()
              finally:
                  res = proc.wait()
          if res != 0:
              if res == 2:
                  signal, code = map(int, result.splitlines()[-1].split())
                  raise SignalError(code, signal)
              elif res == 3:
                  code = int(result.splitlines()[-1].strip())
                  raise ExitError(code)
              raise ExitError(res)
  
          return result
      finally:
          try:
              if fd is not None:
                  _os.close(fd)
          finally:
              _os.unlink(name)
function_tokens: def _pipespawn ( argv , env ) : # pylint: disable = R0912 import pickle as _pickle fd , name = mkstemp ( '.py' ) try : _os . write ( fd , ( r"""
  import os
  import pickle
  try:
      import subprocess
  except ImportError:
      subprocess = None
  import sys
  
  argv = pickle.loads(%(argv)s)
  env = pickle.loads(%(env)s)
  if 'X_JYTHON_WA_PATH' in env:
      env['PATH'] = env['X_JYTHON_WA_PATH']
  
  if subprocess is None:
      pid = os.spawnve(os.P_NOWAIT, argv[0], argv, env)
      result = os.waitpid(pid, 0)[1]
  else:
      p = subprocess.Popen(argv, env=env)
      result = p.wait()
      if result < 0:
          print "\n%%d 1" %% (-result)
          sys.exit(2)
  
  if result == 0:
      sys.exit(0)
  signalled = getattr(os, 'WIFSIGNALED', None)
  if signalled is not None:
      if signalled(result):
          print "\n%%d %%d" %% (os.WTERMSIG(result), result & 7)
          sys.exit(2)
  print "\n%%d" %% (result & 7,)
  sys.exit(3)
          """ . strip ( ) + "\n" ) % { 'argv' : repr ( _pickle . dumps ( argv ) ) , 'env' : repr ( _pickle . dumps ( env ) ) , } ) fd , _ = None , _os . close ( fd ) if _sys . platform == 'win32' : argv = [ ] for arg in [ _sys . executable , name ] : if ' ' in arg or arg . startswith ( '"' ) : arg = '"%s"' % arg . replace ( '"' , '\\"' ) argv . append ( arg ) argv = ' ' . join ( argv ) shell = True close_fds = False else : argv = [ _sys . executable , name ] shell = False close_fds = True res = 0 try : import subprocess except ImportError : import popen2 as _popen2 proc = _popen2 . Popen3 ( argv , False ) try : proc . tochild . close ( ) result = proc . fromchild . read ( ) finally : res = proc . wait ( ) else : if 'X_JYTHON_WA_PATH' in env : env [ 'PATH' ] = env [ 'X_JYTHON_WA_PATH' ] proc = subprocess . Popen ( argv , shell = shell , stdin = subprocess . PIPE , stdout = subprocess . PIPE , close_fds = close_fds , env = env , ) try : proc . stdin . close ( ) result = proc . stdout . read ( ) finally : res = proc . wait ( ) if res != 0 : if res == 2 : signal , code = map ( int , result . splitlines ( ) [ - 1 ] . split ( ) ) raise SignalError ( code , signal ) elif res == 3 : code = int ( result . splitlines ( ) [ - 1 ] . strip ( ) ) raise ExitError ( code ) raise ExitError ( res ) return result finally : try : if fd is not None : _os . close ( fd ) finally : _os . unlink ( name )