Fix gstreamer error messages.
Issue
Running Py3 with an invalid configuration (seeking to a GPS time outside the cache file), @luke.davis encountered this error:
0:03:43.751933259 532715 0x55c4eb83fae0 ERROR basesrc gstbasesrc.c:3674:gst_base_src_start_complete:<lalcachesrc2> Failed to perform initial seek
0:03:43.752006909 532715 0x55c4eb83fae0 WARN basesrc gstbasesrc.c:3917:gst_base_src_activate_push:<lalcachesrc2> Failed to start in push mode
0:03:43.752023553 532715 0x55c4eb83fae0 WARN GST_PADS gstpad.c:1146:gst_pad_set_active:<lalcachesrc2:src> Failed to activate pad
Traceback (most recent call last):
File "/fred/oz016/gwdc_spiir_pipeline_codebase/scripts_n_things/build/ldavis-tdv-use-original-resampler-warp-reduce/install/bin/gstlal_inspiral_postcohspiir_online", line 866, in <module>
msg = pipeline.get_bus().poll(Gst.MESSAGE_ERROR, 0)
File "/usr/spiir/lib/python3.10/site-packages/gi/overrides/__init__.py", line 32, in __getattr__
return getattr(self._introspection_module, name)
File "/usr/spiir/lib/python3.10/site-packages/gi/module.py", line 126, in __getattr__
raise AttributeError("%r object has no attribute %r" % (
AttributeError: 'gi.repository.Gst' object has no attribute 'MESSAGE_ERROR'
Solution
Similar to how Gst.STATE_READY in 0.10 became Gst.State.READY in 1.0, we need similar fixes for Gst.ERROR_MESSAGE. It now uses 'Gst.MessageType.ERROR' instead.
I've also updated some repeated code to use some simple functions I've added to the launch script.
Tests
I've run the new version both with working configuration, and with broken configuration.
The broken config now prints the errors correctly:
error (gst-resource-error-quark:11 'Could not perform seek on resource.'): gstlal_cachesrc.c(701): do_seek (): /GstPipeline:gstlal_inspiral_postcoh_online/GstLALCacheSrc:lalcachesrc1:
no data available for segment
quit: bus.disconnect
quit: del self.on_message_handler_id
quit: bus.remove_signal_watch
quit: self.mainloop.quit
quit: finished
2024-03-13 18:15:33 - gstlal_inspiral_postcohspiir_online - ERROR - (gerror=GLib.Error('Could not perform seek on resource.', 'gst-resource-error-quark', 11), debug='gstlal_cachesrc.c(701): do_seek (): /GstPipeline:gstlal_inspiral_postcoh_online/GstLALCacheSrc:lalcachesrc1:\nno data available for segment')
Traceback (most recent call last):
File "/fred/oz016/tdavies/projects/gstreamer_python_upgrade/install/bin/gstlal_inspiral_postcohspiir_online", line 876, in <module>
set_state_or_raise(pipeline, Gst.State.PLAYING, "Gst.State.PLAYING")
File "/fred/oz016/tdavies/projects/gstreamer_python_upgrade/install/bin/gstlal_inspiral_postcohspiir_online", line 849, in set_state_or_raise
raise RuntimeError(f"Pipeline failed to enter '{state_string}' state")
RuntimeError: Pipeline failed to enter 'Gst.State.PLAYING' state
While the working config does not print any errors:
quit: bus.disconnect
quit: del self.on_message_handler_id
quit: bus.remove_signal_watch
quit: self.mainloop.quit
quit: finished
Although, in my offline tests I am seeing another error Luke's confirmed that he doesn't see this warning in his tests, and I see the same warning before this change in my old tests. I think it's a non-critical issue with my test configuration which I can track down as a low-priority task.sys:1: Warning: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
. I think I found & fixed a similar non-critical issue for Py3 previously, I'll investigate separately to this change.