Calling openrave python script from a windows service crashes on 'env = Environment()'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Calling openrave python script from a windows service crashes on 'env = Environment()'

Jo Mantelers
Hi,

I installed openRave 0.9.0 (vc90, python 2.6.6) on my Win8.1 x64 machine. All works well when running python scripts from command line.

When I call the exact same python script from a Windows service via subprocess.Popen('python.exe ravescript.py', etc) (see bottom of email for exact code) I get below error in windows event log when the line 'env = Environment()' is called.

I made sure all paths are correct, I only have python 2.6.6 installed, and even changed compatibility mode of python.exe and openrave.exe to Win7. No difference.

After two days of googling and testing I ran out of options.

Can somebody please advice where the cause/solution can be found?

Many thanks,
Jo

--- error ---
Faulting application name: python.exe, version: 0.0.0.0, time stamp: 0x4c73f7b6
Faulting module name: MSVCR90.dll, version: 9.0.30729.8387, time stamp: 0x51ea24a5
Exception code: 0xc0000005
Fault offset: 0x0003b9f0
Faulting process ID: 0x16e8
Faulting application start time: 0x01d01920dcad3a2f
Faulting application path: c:\python26\python.exe
Faulting module path: C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387_none_5094ca96bcb6b2bb\MSVCR90.dll
Report ID: 1ab885a8-8514-11e4-bee9-50465de622bb
Faulting package full name:
Faulting package-relative application ID:

--- partial python service install/run code ---

class AppServerSvc (win32serviceutil.ServiceFramework):
    _svc_name_ = "Robot Service"
    _svc_display_name_ = "Robot Service"
    _log = None

    def __init__(self,args):
        win32serviceutil.ServiceFramework.__init__(self,args)
        SetConsoleCtrlHandler(lambda x: True, True)
        self.hWaitStop = win32event.CreateEvent(None,0,0,None)

    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop)
        self.run = False
       
    def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_,''))
        self.run = True
        try:
            self.main()
        except:
            self.writelog('ERROR:')
            self.writelog(traceback.format_exc())
            servicemanager.LogErrorMsg(traceback.format_exc()) # if error print it to event log
            os._exit(-1)#return some value other than 0 to os so that service knows to restart


    def main(self):
        while self.run == True:
            time.sleep(1)
            #self.env has all required paths
            cmd = 'python script.py'
            process = subprocess.Popen( cmd,
                                        env=self.env,
                                        shell=False,
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE,
                                        cwd=cwd)
                   
            stdout, stderr = process.communicate()