[solved] Prepare Phase
Could someone please confirm (or otherwise) that the prepare phase of all Python inline scripts, in ones experiment, are run at the initial start up? (As opposed to being run sequentially, as you progress to the relevant item.)
I noticed that my SQLite connection was getting closed, even though I hadn't issued any close command until the final item's prepare phase. If I move the close into the run phase, then it works... I've been going mad trying to understand why it kept closing itself and the above would be a justifiable explanation ![]()
Thanks;
C
Comments
...although, if that were the case, what is happening with variable assignment? If I declare a variable in the prepare phase, I can still use it in the run phase contextually; that is, it respects any dependencies said variable might have (e.g., a loop index), rather than overwriting the value.
I would be interested in knowing how this works at a technical level. I'm a developer by profession and I'm finding a lot of "gotchas" are to do with my mental model vs. the compromises you've put in place to allow non-developers to use OpenSesame more intuitively. (Not that that's a complaint! I think it's a good design decision, in general, and am impressed that you went to the trouble of implementing it
)
Not exactly. The prepare phase of every item in a
sequence, is executed at the start of thatsequence. So say that you have asequences, with items i1 and i2, then it would go like this:But this happens only at the
sequencelevel; or, put differently,sequences don't have a prepare phase themselves, and everything that you see above would happen as part of asequencerun phase.Does that clear things up? You could visualize the flow of the experiment by having
inline_scriptitems print to the debug window in both the prepare and run phase.See also:
I'm not sure what you mean here. Can you give an example?
That's true, and one of the main challenges when designing OpenSesame.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks, Sebastiaan
That clears everything up and resolves my issue/misunderstanding with variable assignment persistence. I was thinking you must use a closure, or something like that, but Python doesn't really have proper closures. Scoping by sequence is a nice solution