Skip to main content

I am using system caller in child workbench which trigger 3rd party service using command line and start the process e.g. abc.exe in windows. Sometimes process get stuck at their server and I am not able to get the status of the same, hence child workbench continue until any response gets from System caller. Is there any solution to kill the 3rd party process using windows process name or ID if its taking more than a particular time e.g. 1 hr?

Note: I am using FME Desktop with concurrent process of 3 jobs, so it should kill only the process which are not getting finished within 1 hr.

Can anyone help me on this?

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(P"abc.exe", "arg1","arg2",....]), but its failing when I am running using 'arg' variable where cmd = c"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😊


Reply