psychopy.org | Reference | Downloads | Github

Delay in ending a routine

Dear all,

I am having problems in ending a routine. I am using version 1.85.3.

In my experiment there are two blocks. If the participant fails at the first one, she/he will not be able to access Block 2, but will be directly sent at the end message. If she/he does not fail, the experiment will go to Block 2.

To inform them about their eligibility in taking part at Block2 there is a message (Routine eligible_t1). They have to press any button to make the routine ends.

if score_training1 >=1:
    msg_eligible = "You can take part at pt. 2"
    msg_eligible_color = [0.5,0.9,0]
elif score_training1 == 0:
    msg_eligible = "You can not take part at pt. 2"
    msg_eligible_color=[1,0,0]
    not_eligible1 = 1

If they are not eligible a value gets assigned to them: not_eligible = 1.

All the following routines - except for the last one in which I thank the participant - have this code (that I tried to put at Each Frame and Begin Routine as well):

if not_eligible1 == 1:
    continueRoutine = False

What happens however, is that the message You can not take part at pt. 2 will keep to be displayed for quite some time (ca. 5 seconds after the press) and it is not even possible to force the exit with the Esc button. After this seconds, the experiment goes to the last slide, as expected.

As you can see from the Image I am uploading, there is a huge distance between the routine eligible_t1 and the end of the experiment - it didn´t even fit in the screenshot. It is at the end of repeat_trainin_loop1b, once the loop is over.

Thanks :slight_smile:


UPDATE. A less complex case, likely linked to the previous one.

The same thing is happening in another context as well - this is pre_isntructions_b:

Here participants are asked if they want to read the instructions again or not, in Each Frame of code_pre_instr:

if resp_pre_instr.corr:
    pre_instr_value=1
    repeat_training_loop_b.finished=True
    continueRoutine = False

If they press a specific key on the keyboard to say “no”, the instructions should be skipped and the experiment should immediately go to what´s after repeat_training_loop_b (that is, break_tr1_tr2). If they press the key for “yes”, the experiment should enter in the repeat_training_sub loop, where the instructions are repeated.

Both loops work pretty fine, with one problem, as the one described before. If they press “no”, before the experiment skips the loop the question remains on the display for 20sec, like it is getting stuck somewhere.

One thing that might be important to mention is that the instructions in instructions_b contain 5 images of ca. 350 kB each (jpeg). But they shouldn´t be even loaded if I exit the routine with continueRoutine = False.

It should only be necessary in the “Begin routine” tab. But you also need to add this:

your_loop_name.finished = True

Otherwise, the loops will keep running to completion, even if all of the routines within them terminate immediately. This might take some time, even though nothing visible is happening.

Thank you very much! Now it seems to work perfectly :slight_smile: