En Thu, 05 Apr 2007 13:00:52 -0300, Laszlo Nagy <[EMAIL PROTECTED]> escribió:
> p = subprocess.Popen(params, bufsize=1, stdout=fout.fileno(), > stderr=fout.fileno()) > > When I call spawn() from a service, this is written into the logfile: > > 2007-04-05 17:52:53,828 INFO .Spawner Spawing > ['C:\\Python25\\lib\\site-packages\\win32\\PythonService.exe', > 'T:\\Python\\Projects\\Test\\Application.py'] > 2007-04-05 17:52:53,828 ERROR .Spawner Traceback (most recent call last): > File "T:\Python\Projects\Test\Processor.py", line 40, in spawn_downloader > p = subprocess.Popen(params, bufsize=1, stdout=fout.fileno(), > stderr=fout.fileno()) > File "C:\Python25\lib\subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "C:\Python25\lib\subprocess.py", line 681, in _get_handles > p2cread = self._make_inheritable(p2cread) > File "C:\Python25\lib\subprocess.py", line 722, in _make_inheritable > DUPLICATE_SAME_ACCESS) > TypeError: an integer is required With a bit of guessing, I think I've found what's happening. Since you don't provide a value for stdin, None is used. Inside subprocess.py, method _get_handles, line 670, GetStdHandle *may* return None; in that case _make_inheritable fails. If you print the value of p2cread in line 670 I bet you'll get None. The fix is to test for None in _make_inheritable (line 720): if handle is not None: return DuplicateHandle(...) (else return None, implicit) > When I call spawn() from an application, it works just fine. Any ideas? According to http://msdn2.microsoft.com/en-us/library/ms683231.aspx GetStdHandle may return NULL (translated to None in Python) when invoked from a service with no redirected standard handles. From an application, there is no problem. Please try the simple fix above to comfirm it works; I'll submit a patch if that's the case. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list