5
I’m having trouble loading processes from a python application.
Before I was using the subprocess. Popen, but it creates subprocesses of the main application, and in my case, I need to create processes that surround independent, in the sense that, if my application comes down, the processes do not fall.
Another need is to recover the PID from the process - for this reason I am not using the the system.().
I did tests with the the.spawnl(), but I was unsuccessful. Does anyone have any suggestions?
follows the code where I tested the the.spawnl()
>>> import os
>>> programa = r'C:\Program Files (x86)\mongoDB\bin\mongod.exe'
>>> parametros = r'--logpath "C:\Foo\Bar\Base\install.log" --dbpath "C:\Foo\Bar\Base\data\db" --port 1124'
>>> os.path.dirname(programa)
'C:\\Program Files (x86)\\mongoDB\\bin'
>>> os.path.basename(programa)
'mongod.exe'
>>> os.spawnl(os.P_WAIT, os.path.dirname(programa), os.path.basename(programa), parametros)
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
os.spawnl(os.P_WAIT, os.path.dirname(programa), os.path.basename(programa), parametros)
File "C:\Python33\lib\os.py", line 922, in spawnl
return spawnv(mode, file, args)
>>> os.spawnl(os.P_WAIT, "%s %s".format(programa, parametros))
#aqui ocorre crash no pythonw
Hello Michael, thanks for the comment, unfortunately this solution does not suit me for not returning the application’s PID
– drgarcia1986