[open] Inline scripts causes crash
I am running OpenSesame from the source code and using some software libraries for python from Phidgets Inc. When I include the following code in parrallel with a sketchpad image, it causes OpenSesame to crash when the experiment is run (in fact, it causes the experiment to crash before any information is logged in 100% of cases no matter where in the experiment the script is placed). The experiment usually crashes right at the end. I do not think this is a carryover issue, because I am closing OpenSesame each time between runs and also because the crash occurs on the very first run. This script works fine in python's IDLE, and I am wondering how I might fix this issue. The code I am using in the script is as follows: [Thank you in advance for your help, --Mike]
#Prep Phase:
from Phidgets.PhidgetException import *
from Phidgets.Events.Events import *
from Phidgets.Devices.InterfaceKit import *
import time
import random
import createdevice
global RELAY
global IO
IO = createdevice.createdevice()
time.sleep(2)
RELAY = createdevice.createdevice()
try:
DEVICE2 = RELAY.isAttached()
print '1017 is att?: ' + str(DEVICE2)
except:
print 'error'
#Run Phase:
try:
M = RELAY.getOutputState(1)
if M == True:
RELAY.setOutputState(1, False)
elif M == False:
RELAY.setOutputState(1, True)
except:
print 'error'
Comments
Hi Mike,
Could you perhaps provide some more information? What exactly happens when OpenSesame crashes, and do you see any useful debugging output (for example in the debug window)? What platform are you using, and what back-end?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
I am using the Expyriment backend, although I have tried using the Psychopy and Legacy backends and neither changed the nature of the problem. I am using a PC running windows 7. I am unable to see any useful debugging output because when OpenSesame crashes it rapidly closes the application completely, bringing me back to my computer desktop. The crash generally occurs like this: I run the experiment (in either the quickrun or the full run) and it works normally until toward the end (usually in the last or second to last stage, which for me is a sketchpad that has a duration of buttonpress). Upon clicking this last button, which should trigger the end of the experiment and log all the data, the application closes rapidly and brings me back to my desktop.
Best,
Mike
[note: same poster, I made a second account for myself in addition to the one for my lab]
Hi Mike,
I see, yes. These types of hard crashes are always the result of a bug somewhere in a module that is partly coded in C. When a pure Python module, such as OpenSesame, crashes, you will get a nice stacktrace. Assuming that OpenSesame doesn't normally crash this way on your system, the obvious candidate is the
Phidgets
module. The fact that it doesn't crash using IDLE doesn't really say much, because these things can be really unpredictable.If I understand correctly, everything goes fine until the experiment is done, right? And then, instead of closing nicely, the whole things comes crashing down. What might be going on is that the
RELAY
and/ orIO
objects can't handle beingdel
eted after the experiment. As of 0.27.1, OpenSesame cleans up allglobal
s that are registered during the experiment, because the carry-over effects that can result fromglobal
s were giving users considerable headaches. You can see how this works here:You could see what happens if you explicitly delete your
global
s in the script:Alternatively, you can see what happens if you disable the
experiment.restore_state()
:It could be anything though, this is just a guess, but worth trying out.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you Sabastiaan, I will try those solutions and see what happens. I appreciate your help thus far.
Thanks,
Mike
Using your fixes and some other software I am now pretty sure that the problem is that the driver for the relay I am using cannot handle being deleted and that it is a problem with the driver software. Thanks for your help.
--M
PS. I heard that you were going to the APS conference and were going to give a workshop on OpenSesame. I was interested in attending, and was wondering if that would be before or after the main conference?
Glad to hear you tracked it down!
That's a good question. The workshops will be the 23rd (before the conference) and the 26th (after), but I don't see any indication of which workshop will be when. So basically, I don't know yet.
Check out SigmundAI.eu for our OpenSesame AI assistant!