3

When I try running a python script via `twisted.internet.reactor.spawnProcess':

from twisted.internet import protocol, reactor

class ProcessProtocol(protocol.ProcessProtocol):
    def connectionMade(self):
        self.transport.closeStdin()

    def childDataReceived(self, childFD, data):
        print data

def main():
    proto = ProcessProtocol()
    cmd = ['/var/projects/python/worker.py']
    reactor.spawnProcess(proto, cmd[0], cmd)

if __name__ == "__main__":
    exit(main())

I get the following error:

Upon execvpe /var/projects/python/worker.py ['/var/projects/python/worker.py', '5'] in environment id 29011152
:Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/internet/process.py", line 414, in _fork
    executable, args, environment)
  File "/usr/local/lib/python2.6/dist-packages/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/internet/process.py", line 460, in _execChild
    os.execvpe(executable, args, environment)
  File "/usr/lib/python2.6/os.py", line 353, in execvpe
    _execvpe(file, args, env)
  File "/usr/lib/python2.6/os.py", line 368, in _execvpe
    func(file, *argrest)
OSError: [Errno 13] Permission denied
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
  • Are you sure you have the permission to execute `'/var/projects/python/worker.py'`? – Santa Aug 05 '11 at 17:26
  • Are you running your script as root? If not, does the `/var/projects/python/worker.py` file have the right permissions to be read by the user used to run script? – mdeous Aug 05 '11 at 17:26

1 Answers1

4

You might not have the permission to execute '/var/projects/python/worker.py', or that script's execute bit is not set. Do an ls -l /var/projects/python/worker.py and check it?

Santa
  • 11,381
  • 8
  • 51
  • 64
  • 1
    That's what the problem was. I didn't have execute permissions. – Uyghur Lives Matter Aug 05 '11 at 17:40
  • Please feel free to report a documentation bug. http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorProcess.spawnProcess.html really ought to say something about `EACCES` (i.e. errno 13). – Glyph Aug 05 '11 at 20:39