Dear list,
I am new at programming. I am trying to use task developed by someone else using Builder. The task duration is 20 min and if completed before that time is elapsed, a countdown is displayed for the remaining period of time. So for instance if the the participant has spent 15 minutes on the test, the timer will count down from 5min. Unfortunately, after a random amount of time the screen becomes and stays white. However, by printing the remaining time on the command line, I can verify that the task does not crash. This task actually works correctly on some computers.
I know there is not much information to go on here, but any suggestion for tracking this bug down would be appreciated. Is there for example known instance in Psychopy where this white screen might occur? Could there be something linked to the configuration of the videocard?
The timer is initialized as follow:
countDown = core.CountdownTimer(1200) # 20 minutes count down
The actual code for the routine generated by Builder is :
#-------Start Routine "end"-------
continueRoutine = True
while continueRoutine:
# get current time
t = endClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
minsCount = countDown.getTime() / 60
secsCount = countDown.getTime() % 60
if responseQuit=="q":
countdownText="Time remaining: %d minutes %d seconds" % (minsCount, secsCount)
if countDown.getTime()<0:
continueRoutine=False
else:
continueRoutine=False
# *endText* updates
if t >= 0.0 and endText.status == NOT_STARTED:
# keep track of start time/frame for later
endText.tStart = t # underestimates by a little under one frame
endText.frameNStart = frameN # exact frame index
endText.setAutoDraw(True)
if endText.status == STARTED: # only update if being drawn
endText.setText(countdownText, log=False)
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in endComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
core.quit()
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
print 'flip'
Please let me know if you need more information
Kind regards,
Nanna
Dear Micheal,
Thank you for your kind answer. The task was actually implemented by someone else ;) I'm just struggling to make it work.
Everything is handled via standard Builder components. However there is a Builder code component which specifies the conditions to end the timer routine and which contains the code that you pointed out. Unfortunately, due to the missing indentation, you were mislead in thinking that the code was doing the same thing regardless of time, sorry about that. With the correct indentation ;) the snippet of code is as follow:
if responseQuit=="q":
countdownText="Time remaining: %d minutes %d seconds" % (minsCount, secsCount)
if countDown.getTime()<0:
continueRoutine=False
else:
continueRoutine=False
hence time is the factor controlling the end of the routine (responseQuit is almost always equal to "q"). But even if there was a mistake in that "exit" code, it wouldn't explain why the screen randomly becomes blank before the end of the countdown. I do not get an error message when the experiment has been run, I just get a white screen during the test. This is the only output I get:
############# Running: C:\Users\Bruger\Desktop\PRv2_simplified.py ##############
6.1910 WARNING t of last frame was 6.55ms (=1/152)
6.2063 WARNING t of last frame was 6.24ms (=1/160)
6.2221 WARNING t of last frame was 6.03ms (=1/165)
saved data to u'C:\\Users\\Bruger\\Desktop\\Data/999_2015_nov_06_1532_PR.csv'
I've attached a simplified version of the task, including only the last countdown part which crashes. Please let me know if you have any insight on how to fix this problem.
One of the thing I've tried was to change the update of the timer text from "frame" to "repeat", however when doing this the screen stays white and the text is never displayed. I've tried including a loop but the results was the same. Its seems to me rather inefficient to try to update on every frame but I'm not sure what is meant by repeat here.
Cheers,
Nanna.
######### Running: C:\Users\Bruger\Desktop\PRv2_simplified2_lastrun.py #########
saved data to u'C:\\Users\\Bruger\\Desktop\\Data/999_2015_nov_13_0805_PR.csv'
Traceback (most recent call last):
File "C:\Users\Bruger\Desktop\PRv2_simplified2_lastrun.py", line 196, in <module>
win.flip()
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.00-py2.7.egg\psychopy\visual\window.py", line 563, in flip
self._renderFBO()
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.00-py2.7.egg\psychopy\visual\window.py", line 1702, in _renderFBO
GL.glBegin(GL.GL_QUADS)
WindowsError:
exception: access violation writing 0x0003C01C
Best regards,
Nanna