python crash at the end of the experiment
in OpenSesame
I have created this nice piece of code to assess handedness (Oldfield, 1971).
However, it makes my experiment crash at the very end. No matter where i put the code (beginning, middle, or the end). The experiment works well 'till the end. And then... "Python seems to have crashed. This should not happen. If Python crashes often, please report it on the OpenSesame forum."
var.Phase='Handedness'
def handedness_validator():
"""Checks whether all actions have been filled out"""
return (
(var.Hand_1L != u'no' or var.Hand_1R != u'no') and
(var.Hand_2L != u'no' or var.Hand_2R != u'no') and
(var.Hand_3L != u'no' or var.Hand_3R != u'no') and
(var.Hand_4L != u'no' or var.Hand_4R != u'no') and
(var.Hand_5L != u'no' or var.Hand_5R != u'no') and
(var.Hand_6L != u'no' or var.Hand_6R != u'no') and
(var.Hand_7L != u'no' or var.Hand_7R != u'no') and
(var.Hand_8L != u'no' or var.Hand_8R != u'no') and
(var.Hand_9L != u'no' or var.Hand_9R != u'no') and
(var.Hand_10L != u'no' or var.Hand_10R != u'no') )
# Define all widgets
button_ok = Button(text=u'Ok')
label_0 = Label(u'Bitte machen Sie einmal vor, wie sie...')
#label_01 = Label(u'linke Hand')
#label_02 = Label(u'rechte Hand')
label_1 = Label(u'...schreiben')
checkbox_1L = Checkbox(text=u'linke Hand', var=u'Hand_1L')
checkbox_1R = Checkbox(text=u'rechte Hand', var=u'Hand_1R')
label_2 = Label(u'...zeichnen')
checkbox_2L = Checkbox(text=u'linke Hand', var=u'Hand_2L')
checkbox_2R = Checkbox(text=u'rechte Hand', var=u'Hand_2R')
label_3 = Label(u'...einen Ball werfen')
checkbox_3L = Checkbox(text=u'linke Hand', var=u'Hand_3L')
checkbox_3R = Checkbox(text=u'rechte Hand', var=u'Hand_3R')
label_4 = Label(u'...mit einer Schere schneiden')
checkbox_4L = Checkbox(text=u'linke Hand', var=u'Hand_4L')
checkbox_4R = Checkbox(text=u'rechte Hand', var=u'Hand_4R')
label_5 = Label(u'...sich die Zähne putzen')
checkbox_5L = Checkbox(text=u'linke Hand', var=u'Hand_5L')
checkbox_5R = Checkbox(text=u'rechte Hand', var=u'Hand_5R')
label_6 = Label(u'...mit dem Messer Brot schneiden')
checkbox_6L = Checkbox(text=u'linke Hand', var=u'Hand_6L')
checkbox_6R = Checkbox(text=u'rechte Hand', var=u'Hand_6R')
label_7 = Label(u'...mit dem Löffel essen')
checkbox_7L = Checkbox(text=u'linke Hand', var=u'Hand_7L')
checkbox_7R = Checkbox(text=u'rechte Hand', var=u'Hand_7R')
label_8 = Label(u'...mit dem Besen fegen')
checkbox_8L = Checkbox(text=u'linke Hand', var=u'Hand_8L')
checkbox_8R = Checkbox(text=u'rechte Hand', var=u'Hand_8R')
label_9 = Label(u'...ein Streichholz anzünden')
checkbox_9L = Checkbox(text=u'linke Hand', var=u'Hand_9L')
checkbox_9R = Checkbox(text=u'rechte Hand', var=u'Hand_9R')
label_10 = Label(u'...den Deckel von einer Dose schrauben')
checkbox_10L = Checkbox(text=u'linke Hand', var=u'Hand_10L')
checkbox_10R = Checkbox(text=u'rechte Hand', var=u'Hand_10R')
# Build the form. Specify a validator function to make sure that the form is
# completed.
handedness = Form( validator=handedness_validator, cols=[2,1,1,1], rows=13, spacing=10, margins=(10, 100, 100, 100), )
#my_form.set_widget(label_gender, (0, 0))
handedness.set_widget(label_0, (0, 1))
#handedness.set_widget(label_01, (2, 0))
#handedness.set_widget(label_02, (3, 0))
handedness.set_widget(label_1, (0, 2))
handedness.set_widget(checkbox_1L, (2, 2))
handedness.set_widget(checkbox_1R, (3, 2))
handedness.set_widget(label_2, (0, 3))
handedness.set_widget(checkbox_2L, (2, 3))
handedness.set_widget(checkbox_2R, (3, 3))
handedness.set_widget(label_3, (0, 4))
handedness.set_widget(checkbox_3L, (2, 4))
handedness.set_widget(checkbox_3R, (3, 4))
handedness.set_widget(label_4, (0, 5))
handedness.set_widget(checkbox_4L, (2, 5))
handedness.set_widget(checkbox_4R, (3, 5))
handedness.set_widget(label_5, (0, 6))
handedness.set_widget(checkbox_5L, (2, 6))
handedness.set_widget(checkbox_5R, (3, 6))
handedness.set_widget(label_6, (0, 7))
handedness.set_widget(checkbox_6L, (2, 7))
handedness.set_widget(checkbox_6R, (3, 7))
handedness.set_widget(label_7, (0, 8))
handedness.set_widget(checkbox_7L, (2, 8))
handedness.set_widget(checkbox_7R, (3, 8))
handedness.set_widget(label_8, (0, 9))
handedness.set_widget(checkbox_8L, (2, 9))
handedness.set_widget(checkbox_8R, (3, 9))
handedness.set_widget(label_9, (0, 10))
handedness.set_widget(checkbox_9L, (2, 10))
handedness.set_widget(checkbox_9R, (3, 10))
handedness.set_widget(label_10, (0, 11))
handedness.set_widget(checkbox_10L, (2, 11))
handedness.set_widget(checkbox_10R, (3, 11))
handedness.set_widget(button_ok, (2, 12))
handedness._exec()
log.write_vars()
Suggestions for a more effective way to write this are welcomed.
Stephan
Comments
Hi Stephan,
This error ("Python seems to have crashed") is never because you did something wrong. It always reflects a bug somewhere in the low-level libraries used by OpenSesame, or even Python itself (but the former is more likely), that causes the entire Python interpreter to crash. This error occurs at a different level from when a Python script (or OpenSesame experiment) crashes inside the Python interpreter, if that makes sense. It's very difficult to debug this.
In your case, do you experience any negative side-effects? It sometimes happens that Python crashes right when shutting down, and in that case it's annoying, but doesn't really matter.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
you are right. It's annoying, but not really a problem.
I now figured out that the bug only occurs in the 'quick run' but not in 'Run fullscreen'. Hence, it's even less a problem.
To your answer: Sometimes the python crash is caused by errors in the code. If i get the python crash message, i always try to run it several times. And in some cases i get a more specific error report in the second/third try. Usually that happens when i forgot something stupid like not typing
()
aftershow
orlog.write_vars