Reputation: 141
I wrote the code for making the ssh connection. The connection is successful I am executing the command of gstreamer
which run endlessly. I need to kill it after 5 minutes and execute another pipeline.
def execute_pipeline(self,):
print("-------------")
stdin, stdout, stderr = self.ssh_client.exec_command(
command='ls -ll')
for cfg in config.serial_pipeline:
stdin, stdout, stderr = self.ssh_client.exec_command(
command='/media/gst %s' % cfg)
self.ssh_client.exec_command(command="killall -9 gst")
print(stderr.readlines())
self.execute_disply_pipe()
logcreator.log_writer(stdout, cfg)
if the first command is executed then it will not able to execute the next line how to process the things in an asynchronous way?
Upvotes: 0
Views: 162
Reputation: 2949
Run gstreamer
command in the background /media/gst %s &
after that put sleep command
def execute_pipeline(self,):
print("-------------")
stdin, stdout, stderr = self.ssh_client.exec_command(
command='ls -ll')
for cfg in config.serial_pipeline:
stdin, stdout, stderr = self.ssh_client.exec_command(
command='/media/gst %s &' % cfg)
self.ssh_client.exec_command(command="sleep 60")
self.ssh_client.exec_command(command="killall -9 gst")
print(stderr.readlines())
self.execute_disply_pipe()
logcreator.log_writer(stdout, cfg)
Use kill gst process use this command
"ps | grep gst | awk '{print $1}' | xargs kill -2 $1"
Upvotes: 1