My main process/thread starts an executable that starts waiting for a signal after echoing Algorithm loaded
. I am using the subprocess.Popen
class for running the executable.
Later, a thread is started that is supposed to send a signal to the earlier started executable. But I have no clue of how to send a signal to that particular subprocess from that thread.
Is it possible to pass PID
's and "recover" subprocesses using the PID
? The purpose of reusing the process is to send something equivalent to stdin
.
Here's my code for starting the executable:
def start_module():
cmd = '%s/libraries/OpenBR' % settings.MODULES_DIR
process = subprocess.Popen(cmd,stdout=subprocess.PIPE)
while True:
line = process.stdout.readline()
if line.find('Algorithm loaded') > -1:
break
return 0