Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] media_player_gst error

edited July 2015 in OpenSesame

Hello,

I am running an experiment where I show several videos to participants. I run the experiment from opensesamerun.exe and a batch script. However, once the experiment ends, I get the following error: 'media_player_gst' object has no attribute 'gst_loop'. Anyone else run into this issue and have a fix for it?

Comments

  • edited June 2015

    No I haven't encountered this yet, but it sounds as if something goes wrong in the cleanup process. I will see if I can solve this next time I work on the plugin again. For now I have created an issue at https://github.com/dschreij/media_player_gst/issues/

    Buy Me A Coffee

  • edited 11:40PM

    I have the same problem running my experiment inside an OpenSesame instantiation using the "Run fullscreen" button. I use OpenSesame 2.9.6 with Python 2.7.6 on Linux Mint 17.1 with a 3.13.0-52-generic kernel.

    I do not program in Python but I have learned C, C++, Frotran, Pascal, Basic, R, many scripting languages such as bash and awk, and many assembly languages. I can therefore read some of the Python code.

    I cornered the problem to an experiment object imported from the experiment library in /usr/lib/pymodules/python2.7/libqtopensesame/misc/process.py:

    from libopensesame.experiment import experiment
    

    This file creates an experiment object called exp at line 125:

    exp = experiment(string=self.script, pool_folder= \
                    self.pool_folder, experiment_path=self.experiment_path, \
                    fullscreen=self.fullscreen, auto_response=self.auto_response, \
                    subject_nr=self.subject_nr, logfile=self.logfile)
    

    which is then used line 139:

    exp.run()
    

    run() is defined in /usr/lib/pymodules/python2.7/libopensesame/experiment.py line 331. The function definition ends with self.end() defined line 366 in the same file. The last but one instruction of end() is self.cleanup() defined line 357.

        def cleanup(self):
    
            """Calls all the cleanup functions."""
    
            while len(self.cleanup_functions) > 0:
                func = self.cleanup_functions.pop()
                debug.msg(u"calling cleanup function")
                func()
    

    As far as I can understand, there is a list or a tuple or any kind of container cleanup_functions defined in the experiment object that contains the names of functions to be called to cleanup the resources used by the plugin. The faulty function called in the while loop is close_streams defined in media_player_gst.py line 896:

        def close_streams(self):
            """
            A cleanup function, to make sure that the video files are closed and 
            any resources taken up by GStreamer are freed
    
            Returns:
            True on success
            """
            if self.gst_loop.is_running():  
                # Free resources claimed by gstreamer
                self.player.set_state(gst.STATE_NULL)
                # Quit the player's main event loop
                self.gst_loop.quit()
    
    
            return True
    

    The plugins complains about the line if self.gst_loop.is_running(): because:

    AttributeError: 'media_player_gst' object has no attribute 'gst_loop'

    So it seems that a media_player_gst object defined line 536 can be created without the attribute gst_loop. This attribute seems to be created line 604 by the object function prepare(self) defined line 591. I do not know when a media_player_gst object can be created without the gst_loop attribute. I do not know well enough Python and OpenSesame to investigate that issue. I hope that it will not be too difficult for you when you have time to work on the plugin.

    Excuse-me if I did not use the Python vocabulary when I described the concepts. I am used to C++ environment. I just started to learn Python a couple weeks ago just because I decided to use OpenSesame four weeks ago. I only invest one hour from time to time learning Python because I need to work on my projects.

    If I can be of any help despite my low level in OpenSesame and Python, do not hesitate to contact me.

    Best regards and good luck on this issue.

  • edited 11:40PM

    Thanks for diving into this. It think it is safe to say the the cleanup function is no longer necessary if gst_loop is no longer present. This basically means the clean_up function has already been invoked elsewhere before. See my comment on Github for a workaround for this issue: https://github.com/dschreij/media_player_gst/issues/3#issuecomment-114558607. Could you tell me if this worked for your error (It is hard for me to reproduce it). If so, I will commit this change to the main repository.

    Buy Me A Coffee

  • edited 11:40PM

    Thanks to both of you for investigating the issue! I tweaked the code in the media_player_gst.py file as per dshreij's suggestion on github (https://github.com/dschreij/media_player_gst/issues/3#issuecomment-114558607). I did a few runs on the experiment that was giving me the warning, and it appears to have fixed the issue. Hopefully it works for other users!

  • edited 11:40PM

    As I wrote in the github thread with more details, it worked well :-)

    @dschreij: As I wrote in the email sent to you, I wonder where the clean up is done. When I have learned more Python features including class definition with constructor and destructor, I will track down the clean up process to know what is really happening. I will keep you acquainted if I succeed.

    Thanks a lot for the solution, it was a very little bug without real effect on the experiment but nevertheless unpleasant.

Sign In or Register to comment.