[Twisted-Python] spawnProcess with timeout and same error handling on Unix and Windows

Adi Roiban adi at roiban.ro
Wed Sep 3 11:17:01 MDT 2014


On 3 September 2014 16:49, Adi Roiban <adi at roiban.ro> wrote:
> Hi,
>
> If I call spawnProcess with a bad executable, on Unix the process will
> exit with exit code 1 while on Windows an OSError is raised.
>
> I am working on a multi-OS software and to make my life easier I ended
> up with this hack inspired by _BackRelay
>
> https://gist.github.com/adiroiban/bac493f00ce5e94738ce
>
> ----
>
> Is there something already in Twisted doing this? Am I reinventing the wheel?
>
> If not, do you think that it would help to update _BackRelay to
> support timeout and cross-os error handling?
>

Searching the Twisted trac I found this ticket
http://twistedmatrix.com/trac/ticket/4184

Maybe we can leave spawnProcess as the low-level API and then create
another wrapper which will handle/raise the errors in an consistent
way.

For the case where command is not found, I prefer the behaviour from
Windows where an OSError is raise, rather than
looking at errReceived and trying to guess is execvpe call failed or not.


-- 
Adi Roiban




More information about the Twisted-Python mailing list