process.py problems

Justin Johnson justinjohnson at fastmail.fm
Wed Jul 9 13:00:30 EDT 2003


I guess this really is a problem.  I found that it sometimes hangs on
p.stdout.read().

>>> p = process.ProcessOpen("cleartool lsvob -s")
>>> p.stdout.read()
'\\import_test\n\\pvob\n\\vob\n\\adminvob\n\\adminvob2\n'
>>> p = process.ProcessOpen("cleartool lsview -l")
>>> p.stdout.read()
*** just hangs here ***


On Wed, 09 Jul 2003 06:36:28 -0600, "Justin Johnson"
<justinjohnson at fastmail.fm> said:
> Never mind the part about commands hanging....  that appears to be
> related to something else in my code.  I think your process stuff is
> working fine for .exe commands.  :-)
> 
> So just the dir command is failing now.
> 
> On Wed, 09 Jul 2003 06:30:05 -0600, "Justin Johnson"
> <justinjohnson at fastmail.fm> said:
> > After replacing my process.py I still get an error with the dir command
> > (see below).
> > 
> > I'm getting some wierd results with normal .exe commands though. 
> > Commands that don't have much output come back just fine, but commands
> > that have more output, even if they don't take long to run necessarily,
> > seem to get stuck and just hang, never returning.
> > 
> > E:\ccase\python\uhg\uht>python
> > ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
> > Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import process
> > >>> p = process.ProcessOpen("dir")
> > process: info:ProcessOpen.__init__(cmd='dir', mode='t', cwd=None,
> > env=None)
> > process.res: info:[11054544] ProcessOpen._start(): create child stdin:
> > <_FileWra
> > pper: file:None fd:3 os_handle:<PyHANDLE object at 0x00A8ACA4>>
> > process.res: info:[11054544] ProcessOpen._start(): create child stdout:
> > <_FileWr
> > apper: file:None fd:4 os_handle:<PyHANDLE object at 0x00A8D6B4>>
> > process.res: info:[11054544] ProcessOpen._start(): create child stderr:
> > <_FileWr
> > apper: file:None fd:5 os_handle:<PyHANDLE object at 0x00A8D694>>
> > process: debug:_whichFirstArg: first='dir', rest=''
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> >   File "process.py", line 1118, in __init__
> >     self._startOnWindows()
> >   File "process.py", line 1289, in _startOnWindows
> >     cmd = _fixupCommand(cmd, self._env)
> >   File "process.py", line 516, in _fixupCommand
> >     cmd = _whichFirstArg(cmd, env)
> >   File "process.py", line 325, in _whichFirstArg
> >     candidate = which.which(first)
> >   File "which.py", line 251, in which
> >     raise WhichError("Could not find '%s' on the path." % command)
> > which.WhichError: Could not find 'dir' on the path.
> > >>>
> > 
> > >>> p = process.ProcessOpen("cleartool lsvob -l")
> > process: info:ProcessOpen.__init__(cmd='cleartool lsvob -l', mode='t',
> > cwd=None,
> >  env=None)
> > process.res: info:[18469440] ProcessOpen._start(): create child stdin:
> > <_FileWra
> > pper: file:None fd:3 os_handle:<PyHANDLE object at 0x01198B44>>
> > process.res: info:[18469440] ProcessOpen._start(): create child stdout:
> > <_FileWr
> > apper: file:None fd:4 os_handle:<PyHANDLE object at 0x0119CA74>>
> > process.res: info:[18469440] ProcessOpen._start(): create child stderr:
> > <_FileWr
> > apper: file:None fd:5 os_handle:<PyHANDLE object at 0x0119A9E4>>
> > process: debug:_whichFirstArg: first='cleartool', rest='lsvob -l'
> > process: debug:_SaferCreateProcess(appName=None,
> >                     cmd='"C:\\Program
> >                     Files\\Rational\\ClearCase\\bin\\cleartool
> > .EXE" lsvob -l',
> >                     env=None,
> >                     cwd=None)
> >     os.getcwd(): 'E:\\ccase\\python\\uhg\\uht'
> > 
> > process: info:_registerprocess(process=<process.ProcessOpen instance at
> > 0x0119D2
> > 40>)
> > ***** It doesn't return here *****
> > 
> > 
> > On Tue, 8 Jul 2003 17:01:32 -0700, "Trent Mick" <trentm at ActiveState.com>
> > said:
> > > 
> > > Yup, process.py is expected a which.py <1.0. Crappy. I need to put up a
> > > new process.py. To work around in it in your current build you need to
> > > changes process.py's usages of which.which() to expect a single hit
> > > instead of a list of a all hits. In other words, which.which() changed
> > > from:
> > >     >>> which.which("python")
> > >     ["C:\\Python22\\python.exe", "C:\\Python21\\python.exe", ...]
> > > to:
> > >     >>> which.which("python")
> > >     "C:\\Python22\\python.exe"
> > > 
> > > This is a little bit of a pain to do though. I have attached an untested
> > > process.py that should have this fixed. I apologize for the informalness
> > > of this. I'll try to get a new process.py version up on
> > > <starship.python.net/~tmick> when I get a chance.
> > > 
> > > Cheers,
> > > Trent
> > > 
> > > 
> > > [Justin Johnson wrote]
> > > > Thanks for the reply!
> > > > 
> > > > which 1.0.2
> > > > 
> > > > Here's the log output with the dir command
> > > > -----------------------
> > > > process.res: info:[18392288] ProcessOpen._start(): create child stdin:
> > > > <_FileWra
> > > > pper: file:None fd:3 os_handle:<PyHANDLE object at 0x0118C694>>
> > > > process.res: info:[18392288] ProcessOpen._start(): create child stdout:
> > > > <_FileWr
> > > > apper: file:None fd:4 os_handle:<PyHANDLE object at 0x0118C674>>
> > > > process.res: info:[18392288] ProcessOpen._start(): create child stderr:
> > > > <_FileWr
> > > > apper: file:None fd:5 os_handle:<PyHANDLE object at 0x0118C654>>
> > > > process.res: info:[18392288] ProcessOpen.__del__()
> > > > process: info:[18392288] ProcessOpen.close()
> > > > process: info:[18392288] ProcessOpen: closing stdin (<_FileWrapper:
> > > > file:None fd
> > > > :3 os_handle:<PyHANDLE object at 0x0118C694>>).
> > > > process: debug:[18400496] _FileWrapper.close()
> > > > process: debug:[18400496] _FileWrapper.close: close handle
> > > > process: debug:[18400496] _FileWrapper.close: closing handle raised
> > > > process: debug:[18400496] _FileWrapper.close: done closing handle
> > > > process: info:[18392288] ProcessOpen: closing stdout (<_FileWrapper:
> > > > file:None f
> > > > d:4 os_handle:<PyHANDLE object at 0x0118C674>>).
> > > > process: debug:[18400720] _FileWrapper.close()
> > > > process: debug:[18400720] _FileWrapper.close: close handle
> > > > process: debug:[18400720] _FileWrapper.close: closing handle raised
> > > > process: debug:[18400720] _FileWrapper.close: done closing handle
> > > > process: info:[18392288] ProcessOpen: closing stderr (<_FileWrapper:
> > > > file:None f
> > > > d:5 os_handle:<PyHANDLE object at 0x0118C654>>).
> > > > process: debug:[18403024] _FileWrapper.close()
> > > > process: debug:[18403024] _FileWrapper.close: close handle
> > > > process: debug:[18403024] _FileWrapper.close: closing handle raised
> > > > process: debug:[18403024] _FileWrapper.close: done closing handle
> > > > process: debug:[18400720] _FileWrapper.close()
> > > > process: debug:[18400496] _FileWrapper.close()
> > > > process: debug:[18403024] _FileWrapper.close()
> > > > ----------------
> > > > 
> > > > I also get the following results running commands that are in my path...
> > > > ------------------
> > > > g`"apper: file:None fd:5 os_handle:<PyHANDLE object at 0x011D30A4>>
> > > > process: debug:_SaferCreateProcess(appName=None,
> > > >                     cmd='C lsview -s',
> > > >                     env=None,
> > > >                     cwd=None)
> > > >     os.getcwd(): 'E:\\ccase\\python\\uhg\\uht'
> > > > 
> > > > process.res: info:[18680944] ProcessOpen.__del__()
> > > > process: info:[18680944] ProcessOpen.close()
> > > > process: info:[18680944] ProcessOpen: closing stdin (<_FileWrapper:
> > > > file:None fd
> > > > :3 os_handle:<PyHANDLE object at 0x011D4744>>).
> > > > process: debug:[18696880] _FileWrapper.close()
> > > > process: debug:[18696880] _FileWrapper.close: close handle
> > > > process: debug:[18696880] _FileWrapper.close: closing handle raised
> > > > process: debug:[18696880] _FileWrapper.close: done closing handle
> > > > process: info:[18680944] ProcessOpen: closing stdout (<_FileWrapper:
> > > > file:None f
> > > > d:4 os_handle:<PyHANDLE object at 0x011D47C4>>).
> > > > process: debug:[18696832] _FileWrapper.close()
> > > > process: debug:[18696832] _FileWrapper.close: close handle
> > > > process: debug:[18696832] _FileWrapper.close: closing handle raised
> > > > process: debug:[18696832] _FileWrapper.close: done closing handle
> > > > process: info:[18680944] ProcessOpen: closing stderr (<_FileWrapper:
> > > > file:None f
> > > > d:5 os_handle:<PyHANDLE object at 0x011D30A4>>).
> > > > process: debug:[18699984] _FileWrapper.close()
> > > > process: debug:[18699984] _FileWrapper.close: close handle
> > > > process: debug:[18699984] _FileWrapper.close: closing handle raised
> > > > process: debug:[18699984] _FileWrapper.close: done closing handle
> > > > process: debug:[18696832] _FileWrapper.close()
> > > > process: debug:[18696880] _FileWrapper.close()
> > > > process: debug:[18699984] _FileWrapper.close()
> > > > ---------
> > > > 
> > > > 
> > > 
> > > -- 
> > > Trent Mick
> > > TrentM at ActiveState.com
> > 
> > -- 
> > http://mail.python.org/mailman/listinfo/python-list
> > 
> 





More information about the Python-list mailing list