How are you starting the child process in the SystemCaller? If you can get hold of the process id (pid) you can make FME wait for process termination using e.g. a PythonCaller.
Here's an example that takes a list of process ids (pid_list{}) and wait until they've all terminated before the trigger feature is output:
import subprocess
import timeclass
FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        while True:
            process_ids = feature.getAttribute('pid_list{}')
            subprocess_lines = line.split() for line in subprocess.check_output("tasklist").splitlines()]
            running_process_ids = .linet1] for line in subprocess_lines if len(line) > 1]
            is_running = any(running is True for running in i in running_process_ids for i in process_ids])
            if is_running:
                time.sleep(3)
            else:
                break
        self.pyoutput(feature)
    def close(self):
        pass
How are you starting the child process in the SystemCaller? If you can get hold of the process id (pid) you can make FME wait for process termination using e.g. a PythonCaller.
Here's an example that takes a list of process ids (pid_list{}) and wait until they've all terminated before the trigger feature is output:
import subprocess
import timeclass
FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        while True:
            process_ids = feature.getAttribute('pid_list{}')
            subprocess_lines = line.split() for line in subprocess.check_output("tasklist").splitlines()]
            running_process_ids = .linet1] for line in subprocess_lines if len(line) > 1]
            is_running = any(running is True for running in i in running_process_ids for i in process_ids])
            if is_running:
                time.sleep(3)
            else:
                break
        self.pyoutput(feature)
    def close(self):
        pass
The code above takes the output from the command "tasklist" and splits out the process ids. If you prefer, it's also fairly easy to make it look for the name of the executable by changing the index on line 10 above from 1 to 0:
running_process_ids = line 0]  for ...
How are you starting the child process in the SystemCaller? If you can get hold of the process id (pid) you can make FME wait for process termination using e.g. a PythonCaller.
Here's an example that takes a list of process ids (pid_list{}) and wait until they've all terminated before the trigger feature is output:
import subprocess
import timeclass
FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        while True:
            process_ids = feature.getAttribute('pid_list{}')
            subprocess_lines = line.split() for line in subprocess.check_output("tasklist").splitlines()]
            running_process_ids = .linet1] for line in subprocess_lines if len(line) > 1]
            is_running = any(running is True for running in i in running_process_ids for i in process_ids])
            if is_running:
                time.sleep(3)
            else:
                break
        self.pyoutput(feature)
    def close(self):
        pass
Thanks @david_r,
Â
The process is a java program where the call is something like  "java -jar '<some jar file>' -'<some parameters>'"
Â
So the process is java.exe - I could look for and kill the pid relating to a java.exe process if, and only if, there is a single java.exe running. This might be my only option as you say, unless you know of a way to get the ProcessID for something triggered by the SystemCaller with Python...?
Â
Â
Ideally it would be great if there was something I'm missing in the system caller to avoid the need, but perhaps that's wishful thinking :D
Thanks @david_r,
Â
The process is a java program where the call is something like "java -jar '<some jar file>' -'<some parameters>'"
Â
So the process is java.exe - I could look for and kill the pid relating to a java.exe process if, and only if, there is a single java.exe running. This might be my only option as you say, unless you know of a way to get the ProcessID for something triggered by the SystemCaller with Python...?
Â
Â
Ideally it would be great if there was something I'm missing in the system caller to avoid the need, but perhaps that's wishful thinking
It may be easier to just skip the SystemCaller and start your java app using the subprocess.Popen() function in Python: it will return the pid for you to use later on, without having to guess based on the tasklist.
It may be easier to just skip the SystemCaller and start your java app using the subprocess.Popen() function in Python: it will return the pid for you to use later on, without having to guess based on the tasklist.
Ok thanks David, I appreciate the suggestions.
Â
Cheers
That's also one of my issues when I trigger an executable
If the executable has run fairly , the SystemCaller won't end... it keeps running
Also when I stop the workspace running
Another thing / question, related to this one: my batch file or my executable are finished running, but the system caller is still running. So the process in Workspace is not continuing. Is this a related problem or a new question? @david_r @virtualcitymatt ?
Another thing / question, related to this one: my batch file or my executable are finished running, but the system caller is still running. So the process in Workspace is not continuing. Is this a related problem or a new question? @david_r @virtualcitymatt ?
Difficult to say without knowing exactly what process you're starting, and how you're starting it...
Difficult to say without knowing exactly what process you're starting, and how you're starting it...
I'll show my developer it first, then I will get back on it
Â