Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) Jetson
• DeepStream Version 6.0
• JetPack Version (valid for Jetson only) 4.6
• TensorRT Version 8.0
• Issue Type( questions, new requirements, bugs) questions
My current code works fine when started for the first time, but it throws an error upon stopping, and also throws an error when started again for the second time. How can I resolve this issue?
start and stop code:
class DeepStreamApp:
def __init__(self, inputs):
self.inputs = inputs
self.number_sources = len(inputs)
self.pipeline = None
self.loop = None
self._bus_call_received_stop_signal = False
self._stop_requested = False
def _bus_call(self, bus, message, loop):
t = message.type
if t == Gst.MessageType.EOS:
sys.stdout.write("End-of-stream\n")
self._bus_call_received_stop_signal = True
loop.quit()
elif t == Gst.MessageType.WARNING:
err, debug = message.parse_warning()
sys.stderr.write("Warning: %s: %s\n" % (err, debug))
elif t == Gst.MessageType.ERROR:
err, debug = message.parse_error()
self._bus_call_received_stop_signal = True
sys.stderr.write("Error: %s: %s\n" % (err, debug))
loop.quit()
return True
def _pgie_src_pad_buffer_probe(self, pad, info, u_data):
# This method should be overridden by subclasses
pass
def _osd_sink_pad_buffer_probe(self, pad, info, u_data):
# This method should be overridden by subclasses
pass
def _osd_src_pad_buffer_probe(self, pad, info, u_data):
# This method should be overridden by subclasses
pass
def _nvinfer_postprocess(self, output_tensor, **kwargs):
# custom postprocess
pass
def _create_pipeline(self):
# Create and return the pipeline here
raise NotImplementedError("The _create_pipeline method must be implemented by subclasses")
def start(self, retry_interval=5, max_retries=-1):
GObject.threads_init()
Gst.init(None)
retries = 0
should_retry = True
self._stop_requested = False
while should_retry and (max_retries == -1 or retries < max_retries) and not self._stop_requested:
self._bus_call_received_stop_signal = False
self.pipeline = self._create_pipeline()
if not self.pipeline:
sys.stderr.write("Unable to create pipeline\n")
return
self.loop = GObject.MainLoop()
bus = self.pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", self._bus_call, self.loop)
self.pipeline.set_state(Gst.State.PLAYING)
try:
self.loop.run()
except BaseException:
pass
should_retry = self._bus_call_received_stop_signal
if should_retry:
self.pipeline.set_state(Gst.State.NULL)
print(f"Retrying in {retry_interval} seconds...")
time.sleep(retry_interval)
retries += 1
else:
break
def stop(self):
self._stop_requested = True
if self.pipeline:
self.pipeline.set_state(Gst.State.NULL)
if self.loop:
self.loop.quit()