The SystemCaller is fairly simple and it doesn't return the process id.
For your use case, I would recommend using the PythonCaller rather than the SystemCaller.
Starting point:
import subprocess
def ProcessFeature(feature):
process = subprocess.Popen(["echo", "hello"])
print(process.pid)
The SystemCaller is fairly simple and it doesn't return the process id.
For your use case, I would recommend using the PythonCaller rather than the SystemCaller.
Starting point:
import subprocess
def ProcessFeature(feature):
process = subprocess.Popen(["echo", "hello"])
print(process.pid)
Hi @david_r ,
Thank you for the quick response. I will try this one and will get back to you with the updates
Hi @david_r ,
Thank you for the quick response. I will try this one and will get back to you with the updates
Hi @david_r ,
I am a fresher in python, so after exploring https://docs.python.org/3/library/subprocess.html#frequently-used-arguments, I could run below code with hard coded arguments like subprocess.Popen(["abc.exe", "arg1","arg2",....]), but its failing when I am running using 'arg' variable where cmd = ["abc.exe", "arg1","arg2",....]. Is there any syntax error?
import subprocess
def processFeature(feature):
arg = feature.getAttribute('cmd')
proc = subprocess.Popen(arg)
feature.setAttribute("process_id",proc.pid)
try:
outs, errs = proc.communicate(timeout=120)
except subprocess.TimeoutExpired:
proc.kill()
outs, errs = proc.communicate()
feature.setAttribute("IsFailed","T")
Thanks in advance
Hi @david_r ,
Thank you for the quick response. I will try this one and will get back to you with the updates
Just make sure 'arg' is a list, not a string. The function feature.getAttribute() does not return a list, unless you're referencing an FME list attribute.
Hi @david_r ,
Thank you for the quick response. I will try this one and will get back to you with the updates
Thanks @david_r list method worked😊