OpenSesame4 plugin and extension
I am working on updating a plugin and extension for OpenSesame 4. It concerns a custom plugin with extension for communicating with a custom USB marker device that replaces the parallel port for sending markers. The plugin is used to initialize the device and send markers. I added an extension which, after the experiment is finished, opens a tab and presents a table of all the markers that were sent. For OpenSesame 3 I already created this, and everything was working fine. Now I am updating it to work with OpenSesame 4 and I ran into some issues:
- In the OpenSesame 3 version of the plugin I saved several variables in var (self.experiment.var), so that the extension could access them. However, in OpenSesame 4 it seems that I can only save 'simple' variable types in var, like string/integer/float, but for example no lists or dicts. So, what I am doing in OpenSesame 4 is saving variables in the python workspace: self.experiment.python_workspace. This works, but I was wondering why the var variable cannot hold lists or dicts anymore.
- In the plugin, I added a cleanup function (self.experiment.cleanup_functions.append(my_cleanup_func)). In this cleanup function I save variables in the python workspace (as mentioned above) that are later used in the extension. This works fine when the task runs to completion. However, when an error occurs or when the user aborts the experiment, this does not work. That is, the extension cannot find the variables that were saved in the python workspace during the cleanup function. It seems as if in these occasions the extension runs before the cleanup functions run, so that the variables are not saved yet when the extension is getting them. It is a real mystery to me why this happens only when the experiment crashes or is aborted by the user. It is important that these variables are saved during the cleanup function (or at least at the end of the experiment). How can I save some variables at the end of the experiment (whether it is ended by a crash or not) and have them be used by an extension that listens to event_end_experiment?